| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 512 MB | 51 | 34 | 22 | 81.481% |
Recently, Vasya learned how to calculate the number of inversions in a given permutation using Fenwick tree. However, Petya considers it an easy problem, so he decided to make a harder one. Petya asked Vasya to calculate the number of inversions such that the elements divide one another evenly. Formally, for the given permutation $(p_{1}, p_{2}, \ldots, p_{n}),ドル the task is to find the number of pairs of indices $(i, j)$ such that $i < j$ and $p_{i}$ is a multiple of $p_{j}$.
Help Vasya solve this problem.
The first line contains an integer $n,ドル the length of the permutation (1ドル \le n \le 100,000円$). The second line contains $n$ space-separated integers $p_{i}$. It is guaranteed that the given integers form a permutation of integers from 1ドル$ to $n$.
Print one integer: the number of divisible inversions in the given permutation.
5 1 4 3 2 5
1
5 5 4 3 2 1
5