Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
F. Three Chairs

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputOne 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.

Examples

Input

3 1 2 3

Output

1

Input

4 1 6 2 3

Output

3

Input

4 16 4 8 2

Output

0

Input

10 10 1 6 7 9 8 4 3 5 2

Output

77

Note

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.

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/08/2023 20:08:07 (i2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|