from collections import defaultdict n = int(input()) a = list(map(int, input().split())) lim = 400010 ans = 0 cnt = defaultdict(int) for i in range(1, n + 1): for k in range(1, lim//i + 1): ans += cnt[(k, k * i - a[i-1])] cnt[(k, a[i-1] - k * i)] += 1 print(ans)