from collections import defaultdict



N = int(eval(input()))

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



d = defaultdict(int)



for i, a in enumerate(A):

    d[i+a] += 1



ans = 0

for j, a in enumerate(A):

    ans += d[j-a]



print(ans)

from collections import Counter

N = int(eval(input()))

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



s = [i+a for i, a in enumerate(A)]

t = [j-a for j, a in enumerate(A)]



d = Counter(s)

ans = 0



for i in t:

    ans += d[i]

print(ans)
from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(int)
for i, a in enumerate(A):
    d[i + a] += 1
ans = 0
for j, a in enumerate(A):
    ans += d[j - a]
print(ans)

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
s = [i + a for i, a in enumerate(A)]
t = [j - a for j, a in enumerate(A)]
d = Counter(s)
ans = 0
for i in t:
    ans += d[i]
print(ans)

-from collections import defaultdict +from collections import Counter -d = defaultdict(int) -for i, a in enumerate(A): -    d[i + a] += 1 +s = [i + a for i, a in enumerate(A)] +t = [j - a for j, a in enumerate(A)] +d = Counter(s) -for j, a in enumerate(A): -    ans += d[j - a] +for i in t: +    ans += d[i]