#j-i=Ai+Aj(j>i)

#j-Aj=Ai+i



#Lj=Ri=X

from bisect import bisect_left



def main():

    N=int(eval(input()))

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



    L={}

    R={}



    res=0



    for i in range(N):

        l=(i+1)-A[i]

        r=A[i]+i+1

        if (l in list(R.keys())):

            res+=len(R[l])

        if (r in list(R.keys())):

            R[r].append(i+1)

        else:

            R[r]=[i+1]





    print(res)



if __name__=="__main__":

    main()







def main():

    N=int(eval(input()))

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



    L={}

    R={}



    for i in range(N):

        l=(i+1)+A[i]

        r=(i+1)-A[i]

        if (l in list(L.keys())):

            L[l]+=1

        else:

            L[l]=1

        if r in list(R.keys()):

            R[r]+=1

        else:

            R[r]=1



    res=0

    for key in list(L.keys()):

        if key in list(R.keys()):

            res+=R[key]*L[key]



    print(res)

if __name__=="__main__":

    main()

# j-i=Ai+Aj(j>i)
# j-Aj=Ai+i
# Lj=Ri=X
from bisect import bisect_left


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    L = {}
    R = {}
    res = 0
    for i in range(N):
        l = (i + 1) - A[i]
        r = A[i] + i + 1
        if l in list(R.keys()):
            res += len(R[l])
        if r in list(R.keys()):
            R[r].append(i + 1)
        else:
            R[r] = [i + 1]
    print(res)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    L = {}
    R = {}
    for i in range(N):
        l = (i + 1) + A[i]
        r = (i + 1) - A[i]
        if l in list(L.keys()):
            L[l] += 1
        else:
            L[l] = 1
        if r in list(R.keys()):
            R[r] += 1
        else:
            R[r] = 1
    res = 0
    for key in list(L.keys()):
        if key in list(R.keys()):
            res += R[key] * L[key]
    print(res)


if __name__ == "__main__":
    main()

-# j-i=Ai+Aj(j>i) -# j-Aj=Ai+i -# Lj=Ri=X -from bisect import bisect_left - - +    for i in range(N): +        l = (i + 1) + A[i] +        r = (i + 1) - A[i] +        if l in list(L.keys()): +            L[l] += 1 +        else: +            L[l] = 1 +        if r in list(R.keys()): +            R[r] += 1 +        else: +            R[r] = 1 -    for i in range(N): -        l = (i + 1) - A[i] -        r = A[i] + i + 1 -        if l in list(R.keys()): -            res += len(R[l]) -        if r in list(R.keys()): -            R[r].append(i + 1) -        else: -            R[r] = [i + 1] +    for key in list(L.keys()): +        if key in list(R.keys()): +            res += R[key] * L[key]