import numpy as np

import sys

import math

import collections

read = sys.stdin.readline



N = int(read().rstrip())

A = list(map(int,read().rstrip().split()))

da = []

for i , a in enumerate(A):

    da.append([i,a])



dR = collections.defaultdict(int)

dL = collections.defaultdict(int)



ans = 0

for d in reversed(da):

    r = d[0] + d[1] + 1

    l = d[0] - d[1] + 1 



    dR[r] += 1



    ans += dL[r]



    dL[l] += 1  



print(ans)
import numpy as np

import sys

import math

read = sys.stdin.readline



N = int(read().rstrip())

A = list(map(int,read().rstrip().split()))

da = []

for i , a in enumerate(A):

    da.append([i,a])



dR = {}

dL = {}



ans = 0

for d in reversed(da):

    r = d[0] + d[1] + 1

    l = d[0] - d[1] + 1 

    if r in dR:

        dR[r] += 1

    else:

        dR[r] = 1



    if r in dL:

        ans += dL[r]



    if l in dL :

        dL[l] += 1

    else:

        dL[l] = 1  



print(ans)

import numpy as np
import sys
import math
import collections

read = sys.stdin.readline
N = int(read().rstrip())
A = list(map(int, read().rstrip().split()))
da = []
for i, a in enumerate(A):
    da.append([i, a])
dR = collections.defaultdict(int)
dL = collections.defaultdict(int)
ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1
    dR[r] += 1
    ans += dL[r]
    dL[l] += 1
print(ans)

import numpy as np
import sys
import math

read = sys.stdin.readline
N = int(read().rstrip())
A = list(map(int, read().rstrip().split()))
da = []
for i, a in enumerate(A):
    da.append([i, a])
dR = {}
dL = {}
ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1
    if r in dR:
        dR[r] += 1
    else:
        dR[r] = 1
    if r in dL:
        ans += dL[r]
    if l in dL:
        dL[l] += 1
    else:
        dL[l] = 1
print(ans)

-import collections -dR = collections.defaultdict(int) -dL = collections.defaultdict(int) +dR = {} +dL = {} -    dR[r] += 1 -    ans += dL[r] -    dL[l] += 1 +    if r in dR: +        dR[r] += 1 +    else: +        dR[r] = 1 +    if r in dL: +        ans += dL[r] +    if l in dL: +        dL[l] += 1 +    else: +        dL[l] = 1