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

#SP0000165. Hàm không chứa bình phương (Square-free Function)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Hàm không chứa bình phương (Square-free Function)

Square-free Function

Phuoc Hung OJ problem: PRIME000170
Reference: CodeChef SQUAREFU
Adaptation: one original query per PHOJ execution; subtasks are PHOJ-specific groups.

Problem statement

Given an array AA of NN positive integers, let F(x)=x/yF(x)=x/y where yy is the largest perfect square dividing xx. Count index pairs 1≤i<j≤N1\le i<j\le N such that F(AiAj)>1F(A_i A_j)>1.

Input

The first line contains NN; the second line contains NN integers AiA_i.

Output

Print one integer: the number of good pairs.

Subtasks

  • Subtask 1 (20 points): 1≤N≤121\le N\le 12, 1≤Ai≤1001\le A_i\le100.
  • Subtask 2 (30 points): 13≤N≤100013\le N\le1000, 1≤Ai≤1041\le A_i\le10^4.
  • Subtask 3 (50 points): 1001≤N≤2⋅1051001\le N\le2\cdot10^5, 1≤Ai≤1061\le A_i\le10^6.

Example

Input

4
2 8 18 3

Output

3

Explanation: The square-free kernels are 2,2,2,32,2,2,3. Only the three pairs involving the final element have a non-square product, so the answer is 33.