import bisect

N = int(eval(input()))

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

alist = [0] + alist

sumlist = []

# (j, wj)のリストを作る

for i in range(1,N+1):

    sumlist.append(i+alist[i])

sumlist.sort()

ans = 0

# 差と一致するものを探す

for i in range(1, N+1):

    diff = i - alist[i]

    if diff <= 0:

        continue

    i = bisect.bisect_left(sumlist, diff)

    j = bisect.bisect_right(sumlist, diff)

    ans += j - i

print(ans)
from collections import Counter



N = int(eval(input()))

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

alist = [0] + alist

sumlist = []

# (j, wj)のリストを作る

for i in range(1,N+1):

    sumlist.append(i+alist[i])

sumlist.sort()

sum_cnt = Counter(sumlist)

ans = 0

# 差と一致するものを探す

for i in range(1, N+1):

    diff = i - alist[i]

    if diff in sum_cnt:

        ans += sum_cnt[diff]

print(ans)
import bisect

N = int(eval(input()))
alist = list(map(int, input().split()))
alist = [0] + alist
sumlist = []
# (j, wj)のリストを作る
for i in range(1, N + 1):
    sumlist.append(i + alist[i])
sumlist.sort()
ans = 0
# 差と一致するものを探す
for i in range(1, N + 1):
    diff = i - alist[i]
    if diff <= 0:
        continue
    i = bisect.bisect_left(sumlist, diff)
    j = bisect.bisect_right(sumlist, diff)
    ans += j - i
print(ans)

from collections import Counter

N = int(eval(input()))
alist = list(map(int, input().split()))
alist = [0] + alist
sumlist = []
# (j, wj)のリストを作る
for i in range(1, N + 1):
    sumlist.append(i + alist[i])
sumlist.sort()
sum_cnt = Counter(sumlist)
ans = 0
# 差と一致するものを探す
for i in range(1, N + 1):
    diff = i - alist[i]
    if diff in sum_cnt:
        ans += sum_cnt[diff]
print(ans)

-import bisect +from collections import Counter +sum_cnt = Counter(sumlist) -    if diff <= 0: -        continue -    i = bisect.bisect_left(sumlist, diff) -    j = bisect.bisect_right(sumlist, diff) -    ans += j - i +    if diff in sum_cnt: +        ans += sum_cnt[diff]