P5962 [CF1780F] Three Chairs
提高+
题目描述

One day Kira found $n$ friends from Morioh and decided to gather them around a table to have a peaceful conversation. The height of friend $i$ is equal to $a_i$. It so happened that the height of each of the friends is unique.

Unfortunately, there were only $3$ chairs in Kira's house, and obviously, it will not be possible to seat all friends! So, Kira has to invite only $3$ of his friends.

But everything is not so simple! If the heights of the lowest and the tallest of the invited friends are not coprime, then the friends will play tricks on each other, which will greatly anger Kira.

Kira became interested, how many ways are there to choose $3$ of his friends so that they don't play tricks? Two ways are considered different if there is a friend invited in one way, but not in the other.

Formally, if Kira invites friends $i$, $j$, and $k$, then the following should be true: $\gcd(\min(a_i, a_j, a_k), \max(a_i, a_j, a_k)) = 1$, where $\gcd(x, y)$ denotes the greatest common divisor (GCD) of the numbers $x$ and $y$.

Kira is not very strong in computer science, so he asks you to count the number of ways to invide friends.

Input

The first line contains the number $n$ ($3 \le n \le 3\cdot10^5$) — the number of Kira's friends.

The next line contains $n$ distinct integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 3\cdot10^5$) — heights of Kira's friends.

Output

In a single line output the number of ways to invite three friends.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 2 3
样例输出
1
提示

In the first example, only one way is suitable: invite friends $1$, $2$, and $3$. Here $1 < 2 < 3$, and the numbers $1$ and $3$ are coprime.