#!python3



from collections import defaultdict



iim = lambda: list(map(int, input().rstrip().split()))



def resolve():

    N = int(eval(input()))

    A = list(iim())



    d1 = defaultdict(int)

    d2 = defaultdict(int)

    for i, ai in enumerate(A):

        d1[i+ai] += 1

        d2[i-ai] += 1



    ans = 0

    for k, v in list(d1.items()):

        if k in d2:

            ans += v * d2[k]



    print(ans)



if __name__ == "__main__":

    resolve()

#!python3



from collections import defaultdict



iim = lambda: list(map(int, input().rstrip().split()))



def resolve():

    N = int(eval(input()))

    A = list(iim())



    ans = 0

    dp = [0]*N

    for i, ai in enumerate(A):

        x = i + ai

        if x < N:

            dp[x] += 1

        x = i - ai

        if x >= 0:

            ans += dp[x]



    print(ans)



if __name__ == "__main__":

    resolve()

#!python3
from collections import defaultdict

iim = lambda: list(map(int, input().rstrip().split()))


def resolve():
    N = int(eval(input()))
    A = list(iim())
    d1 = defaultdict(int)
    d2 = defaultdict(int)
    for i, ai in enumerate(A):
        d1[i + ai] += 1
        d2[i - ai] += 1
    ans = 0
    for k, v in list(d1.items()):
        if k in d2:
            ans += v * d2[k]
    print(ans)


if __name__ == "__main__":
    resolve()

#!python3
from collections import defaultdict

iim = lambda: list(map(int, input().rstrip().split()))


def resolve():
    N = int(eval(input()))
    A = list(iim())
    ans = 0
    dp = [0] * N
    for i, ai in enumerate(A):
        x = i + ai
        if x < N:
            dp[x] += 1
        x = i - ai
        if x >= 0:
            ans += dp[x]
    print(ans)


if __name__ == "__main__":
    resolve()

-    d1 = defaultdict(int) -    d2 = defaultdict(int) +    ans = 0 +    dp = [0] * N -        d1[i + ai] += 1 -        d2[i - ai] += 1 -    ans = 0 -    for k, v in list(d1.items()): -        if k in d2: -            ans += v * d2[k] +        x = i + ai +        if x < N: +            dp[x] += 1 +        x = i - ai +        if x >= 0: +            ans += dp[x]