from collections import defaultdict

n = int(eval(input()))

a = [int(i) for i in input().split()]

d = defaultdict(int)

for i in range(n): d[i+1+a[i]] += 1

ans = 0

for j in range(n): ans += d[j+1-a[j]]

print(ans)
from collections import defaultdict

n = int(eval(input()))

a = [int(i) for i in input().split()]

ans = 0

d = defaultdict(int)

for i in range(n):

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

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

print(ans)
from collections import defaultdict

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

from collections import defaultdict

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

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