#abc200c. C - Ringo's Favorite Numbers 2

C - Ringo's Favorite Numbers 2

Score : 300300 points

问题描述

Ringo 喜爱整数 200200。为他解决下面的问题。

给定一个包含 NN 个正整数的序列 AA,找出满足以下所有条件的一对整数 (i,j)(i, j)

  • 1i<jN1 \le i < j \le N
  • AiAjA_i - A_j200200 的倍数。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Ringo loves the integer 200200. Solve the problem below for him.
Given a sequence AA of NN positive integers, find the pair of integers (i,j)(i, j) satisfying all of the following conditions:

  • 1i<jN1 \le i < j \le N;
  • AiAjA_i - A_j is a multiple of 200200.

Constraints

  • All values in input are integers.
  • 2N2×1052 \le N \le 2 \times 10^5
  • 1Ai1091 \le A_i \le 10^9

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \dots ANA_N

Output

Print the answer as an integer.

Sample Input 1

6
123 223 123 523 200 2000

Sample Output 1

4

For example, for (i,j)=(1,3)(i, j) = (1, 3), A1A3=0A_1 - A_3 = 0 is a multiple of 200200.
We have four pairs satisfying the conditions: (i,j)=(1,3),(1,4),(3,4),(5,6)(i,j)=(1,3),(1,4),(3,4),(5,6).

Sample Input 2

5
1 2 3 4 5

Sample Output 2

0

There may be no pair satisfying the conditions.

Sample Input 3

8
199 100 200 400 300 500 600 200

Sample Output 3

9

update @ 2024/3/10 09:11:31