from collections import defaultdict

d = defaultdict(int)

N = int(eval(input()))

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

ans = 0

for i in range(N):

    ans += d[(i+1)-arr[i]]

    d[(i+1)+arr[i]] += 1

print(ans)
from collections import defaultdict

N = int(eval(input()))

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

d = defaultdict(int)

ans = 0

for i in range(N):

    if i-arr[i] >= 0:

        ans += d[i-arr[i]]

    d[i+arr[i]] += 1

print(ans)
from collections import defaultdict

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

from collections import defaultdict

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

-d = defaultdict(int) +d = defaultdict(int) -    ans += d[(i + 1) - arr[i]] -    d[(i + 1) + arr[i]] += 1 +    if i - arr[i] >= 0: +        ans += d[i - arr[i]] +    d[i + arr[i]] += 1