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

d=[0]*n

def main():

 for i,x in enumerate(a):

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

 print((sum([d[i-x]for i,x in enumerate(a)if i-x>=0])))

main()
def main():

 n,a=int(eval(input())),list(map(int, input().split()));d,s=[0]*n,0

 for i,x in enumerate(a):

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

  if i-x>=0:s+=d[i-x]

 print(s)

main()
n, a = int(eval(input())), list(map(int, input().split()))
d = [0] * n


def main():
    for i, x in enumerate(a):
        if i + x < n:
            d[i + x] += 1
    print((sum([d[i - x] for i, x in enumerate(a) if i - x >= 0])))


main()

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


main()

-n, a = int(eval(input())), list(map(int, input().split())) -d = [0] * n - - +    n, a = int(eval(input())), list(map(int, input().split())) +    d, s = [0] * n, 0 -    print((sum([d[i - x] for i, x in enumerate(a) if i - x >= 0]))) +        if i - x >= 0: +            s += d[i - x] +    print(s)