from collections import defaultdict n = int(input()) a = list(map(int, input().split())) assert 2 <= n <= 2 * 10 ** 5 for x in a: assert 1 <= x <= 2 * 10 ** 5 lim = 400010 ans = 0 for k in range(1, lim): cnt = defaultdict(int) for i in range(1, n + 1): if i * k >= lim: break p = k*i-a[i-1] ans += cnt[-p] cnt[p] += 1 print(ans)