PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000093. Bộ ba chỉ số (Index Trio)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bộ ba chỉ số (Index Trio)

Index Trio

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given a sequence of positive integers A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N), count the ordered index triples (i,j,k)(i,j,k) satisfying 1≤i,j,k≤N1\le i,j,k\le N and Ai/Aj=AkA_i/A_j=A_k. Indices may coincide, and different ordered triples are counted separately. Since all values are positive integers, the condition is equivalent to Ai=Aj⋅AkA_i=A_j\cdot A_k.

Input

The first line contains NN. The second line contains exactly NN positive integers A1,A2,…,ANA_1,A_2,\ldots,A_N.

Output

Print one integer: the number of valid ordered index triples.

Subtasks

  • Subtask 1 (20 points): 1≤N≤301\le N\le 30; 1≤Ai≤1001\le A_i\le 100 for every 1≤i≤N1\le i\le N.
  • Subtask 2 (30 points): 1≤N≤20001\le N\le 2000; 1≤Ai≤30001\le A_i\le 3000 for every 1≤i≤N1\le i\le N.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000; 1≤Ai≤2000001\le A_i\le 200000 for every 1≤i≤N1\le i\le N.

Examples

Input

3
6 2 3

Output

2

Explanation

The values are A1=6,A2=2,A3=3A_1=6,A_2=2,A_3=3. For i=1i=1, both A1=A2⋅A3=2⋅3A_1=A_2\cdot A_3=2\cdot3 and A1=A3⋅A2=3⋅2A_1=A_3\cdot A_2=3\cdot2 hold. These yield (1,2,3)(1,2,3) and (1,3,2)(1,3,2); no other triple is valid. Print 2.