[ABC230G] 双重非互质排列对 (GCD Permutation)
Score : points
Problem Statement
Given is a permutation of the integers from through .
Find the number of pairs of integers such that satisfying and .
Here, for positive integers and , denotes the greatest common divisor of and .
Constraints
-
-
is a permutation of .
-
All values in input are integers.
Input
Input is given from Standard Input in the following format:
$N$
$P_1$ $P_2$ $\ldots$ $P_N$
Output
Print the answer.
Sample Input 1
6
5 1 3 2 4 6
Sample Output 1
6
Six pairs , , , , , satisfy the condition, so should be printed.
Sample Input 2
12
1 2 3 4 5 6 7 8 9 10 11 12
Sample Output 2
32