from collections import defaultdict

n=int(eval(input()))

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

d=defaultdict(int)

for i in range(n):

    d[i+1-a[i]]+=1

print((sum(d[i+1+a[i]] for i in range(n))))
from collections import defaultdict

n=int(eval(input()))

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

d=defaultdict(int)

for i in range(n):

    d[i-a[i]]+=1

ans=0

for i in range(n):

    ans+=d[i+a[i]]

print(ans)
from collections import defaultdict

n = int(eval(input()))
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
    d[i + 1 - a[i]] += 1
print((sum(d[i + 1 + a[i]] for i in range(n))))

from collections import defaultdict

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

-    d[i + 1 - a[i]] += 1 -print((sum(d[i + 1 + a[i]] for i in range(n)))) +    d[i - a[i]] += 1 +ans = 0 +for i in range(n): +    ans += d[i + a[i]] +print(ans)