from collections import defaultdict

N = int(eval(input()))

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

cnt1 = defaultdict(int)

cnt2 = defaultdict(int)

for i in range(N):

    cnt1[A[i] + i + 1] += 1

    cnt2[i + 1 - A[i]] += 1

ans = 0

for k, v in list(cnt1.items()):

    ans += v * cnt2[k]

print(ans)
from collections import defaultdict

N = int(eval(input()))

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

cnt = defaultdict(int)

ans = 0

for i, x in enumerate(A, 1):

    # print(i, x)

    ans += cnt[i - x]

    cnt[x + i] += 1

print(ans)
from collections import defaultdict

N = int(eval(input()))
A = list(map(int, input().split()))
cnt1 = defaultdict(int)
cnt2 = defaultdict(int)
for i in range(N):
    cnt1[A[i] + i + 1] += 1
    cnt2[i + 1 - A[i]] += 1
ans = 0
for k, v in list(cnt1.items()):
    ans += v * cnt2[k]
print(ans)

from collections import defaultdict

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

-cnt1 = defaultdict(int) -cnt2 = defaultdict(int) -for i in range(N): -    cnt1[A[i] + i + 1] += 1 -    cnt2[i + 1 - A[i]] += 1 +cnt = defaultdict(int) -for k, v in list(cnt1.items()): -    ans += v * cnt2[k] +for i, x in enumerate(A, 1): +    # print(i, x) +    ans += cnt[i - x] +    cnt[x + i] += 1