Sum of Pairwise GCDs
Print ∑i<j gcd(ai, aj).
Input: the first line has N; the second line has N positive integers.
Output: the sum of gcd over all pairs.
Constraints:
- 2 ≤ N ≤ 105
- 1 ≤ ai ≤ 105
Sample Tests
Input 1
3 2 4 6
Output 1
6
Input 2
2 5 5
Output 2
5
Discussion (opens after you solve — no spoilers before)
No comments yet.