from collections import defaultdict

N = int(eval(input()))

A = list(map(int, input().split()))

B = A[:]

for n in range(N):

    B[n] -= (n + 1)



D = defaultdict(int)

ans = 0

for i, a, b in zip(reversed(list(range(N))), A[::-1], B[::-1]):

    ans += D[-(i + a + 1)]

    D[b] += 1



print(ans)

from collections import Counter

N = int(eval(input()))

A = list(map(int, input().split()))



P = [i + a for i, a in enumerate(A, start=1)]

Q = [j - a for j, a in enumerate(A, start=1)]



ans = 0

QC = Counter(Q)

for p in P:

    ans += QC[p]



print(ans)

from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
B = A[:]
for n in range(N):
    B[n] -= n + 1
D = defaultdict(int)
ans = 0
for i, a, b in zip(reversed(list(range(N))), A[::-1], B[::-1]):
    ans += D[-(i + a + 1)]
    D[b] += 1
print(ans)

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
P = [i + a for i, a in enumerate(A, start=1)]
Q = [j - a for j, a in enumerate(A, start=1)]
ans = 0
QC = Counter(Q)
for p in P:
    ans += QC[p]
print(ans)

-from collections import defaultdict +from collections import Counter -B = A[:] -for n in range(N): -    B[n] -= n + 1 -D = defaultdict(int) +P = [i + a for i, a in enumerate(A, start=1)] +Q = [j - a for j, a in enumerate(A, start=1)] -for i, a, b in zip(reversed(list(range(N))), A[::-1], B[::-1]): -    ans += D[-(i + a + 1)] -    D[b] += 1 +QC = Counter(Q) +for p in P: +    ans += QC[p]