n = int(eval(input()))

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

ans = 0

d = {}

for i in range(n):

  if d.get(i+a[i],0)==0:

    d[i+a[i]] = [0,0]

  if d.get(i-a[i],0)==0:

    d[i-a[i]] = [0,0]

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

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

for v in list(d.values()):

  ans += v[0]*v[1]

print(ans)
import collections

n = int(eval(input()))

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

ans = 0

cnt = collections.defaultdict(int)

for i in range(n):

  ans += cnt[i-a[i]]

  cnt[i+a[i]]+=1

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
d = {}
for i in range(n):
    if d.get(i + a[i], 0) == 0:
        d[i + a[i]] = [0, 0]
    if d.get(i - a[i], 0) == 0:
        d[i - a[i]] = [0, 0]
    d[i + a[i]][0] += 1
    d[i - a[i]][1] += 1
for v in list(d.values()):
    ans += v[0] * v[1]
print(ans)

import collections

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

+import collections + -d = {} +cnt = collections.defaultdict(int) -    if d.get(i + a[i], 0) == 0: -        d[i + a[i]] = [0, 0] -    if d.get(i - a[i], 0) == 0: -        d[i - a[i]] = [0, 0] -    d[i + a[i]][0] += 1 -    d[i - a[i]][1] += 1 -for v in list(d.values()): -    ans += v[0] * v[1] +    ans += cnt[i - a[i]] +    cnt[i + a[i]] += 1