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

#GL0000236. Đếm cặp không có ước chung xuất hiện (Counting Rhyme)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đếm cặp không có ước chung xuất hiện (Counting Rhyme)

Đếm cặp không có ước chung xuất hiện (Counting Rhyme)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Count pairs i<ji<j for which there does not exist any array element aka_k dividing both aia_i and aja_j. The witness index kk may coincide with ii or jj.

Input

  • First line: integer nn.
  • Second line: nn array elements.

Output

Print the number of good pairs.

Subtasks

  • Subtask 1 (20 points): 1≤n≤20, 1≤ai≤n1\le n\le20,\ 1\le a_i\le n.
  • Subtask 2 (30 points): 1≤n≤5000, 1≤ai≤n1\le n\le5000,\ 1\le a_i\le n.
  • Subtask 3 (50 points): 1≤n≤106, 1≤ai≤n1\le n\le10^6,\ 1\le a_i\le n.

Examples

Example 1

Input

4
2 3 4 4

Output

3

Explanation

The three good pairs are (1,2),(2,3),(2,4)(1,2),(2,3),(2,4).

Example 2

Input

4
2 4 4 4

Output

0

Explanation

Each pair has a common divisor equal to 2, which is present in the input.