n = int(eval(input()))

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

d = [0]*n

for i in range(n):

  if i+a[i] < n: d[i+a[i]] += 1

ans = 0

for i in range(n):

  if i-a[i] >= 0: ans += d[i-a[i]]

print(ans)
def main():

  n = int(eval(input()))

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

  d = [0]*n

  for i in range(n):

    if i+a[i] < n: d[i+a[i]] += 1

  ans = 0

  for i in range(n):

    if i-a[i] >= 0: ans += d[i-a[i]]

  print(ans)

main()
n = int(eval(input()))
a = list(map(int, input().split()))
d = [0] * n
for i in range(n):
    if i + a[i] < n:
        d[i + a[i]] += 1
ans = 0
for i in range(n):
    if i - a[i] >= 0:
        ans += d[i - a[i]]
print(ans)

def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    d = [0] * n
    for i in range(n):
        if i + a[i] < n:
            d[i + a[i]] += 1
    ans = 0
    for i in range(n):
        if i - a[i] >= 0:
            ans += d[i - a[i]]
    print(ans)


main()

-n = int(eval(input())) -a = list(map(int, input().split())) -d = [0] * n -for i in range(n): -    if i + a[i] < n: -        d[i + a[i]] += 1 -ans = 0 -for i in range(n): -    if i - a[i] >= 0: -        ans += d[i - a[i]] -print(ans) +def main(): +    n = int(eval(input())) +    a = list(map(int, input().split())) +    d = [0] * n +    for i in range(n): +        if i + a[i] < n: +            d[i + a[i]] += 1 +    ans = 0 +    for i in range(n): +        if i - a[i] >= 0: +            ans += d[i - a[i]] +    print(ans) + + +main()