from collections import defaultdict from bisect import bisect_left, bisect_right N = int(input()) M = 200000 A = list(map(int, input().split())) C = [[] for i in range(2*M+1)] for i in range(N): for d in range(1, (A[i] + M) // (i+1) + 1): C[d].append(A[i] - (i+1) * d) ans = 0 for d in range(1, (2 * M) // 3 + 1): C[d].sort() cnt0 = 0 for c in C[d]: if c > 0: break elif c == 0: cnt0 += 1 else: ans += bisect_right(C[d], -c) - bisect_left(C[d], -c) ans += cnt0 * (cnt0 - 1) // 2 print(ans)