from collections import Counter

import bisect





def make_divisors(n):

    divisors = []

    for i in range(1, int(n ** 0.5) + 1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n // i)



    # divisors.sort()

    return divisors





if __name__ == '__main__':

    N = int(eval(input()))

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

    negA = []

    idx_negA = []

    for i, a in enumerate(A):

        negA.append(i - a)

        idx_negA.append(i)



    cnt_negA = Counter(negA)

    negA_keys = sorted(cnt_negA.keys())

    ans = 0

    for i in range(N):

        if i + A[i] in cnt_negA:

            ans += cnt_negA[i + A[i]]

    print(ans)

from collections import Counter

import bisect





def make_divisors(n):

    divisors = []

    for i in range(1, int(n ** 0.5) + 1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n // i)



    # divisors.sort()

    return divisors





if __name__ == '__main__':

    N = int(eval(input()))

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

    negA = []

    for i, a in enumerate(A):

        negA.append(i - a)



    cnt_negA = Counter(negA)

    negA_keys = sorted(cnt_negA.keys())

    ans = 0

    for i in range(N):

        if i + A[i] in cnt_negA:

            ans += cnt_negA[i + A[i]]

    print(ans)

from collections import Counter
import bisect


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort()
    return divisors


if __name__ == "__main__":
    N = int(eval(input()))
    A = list(map(int, input().split()))
    negA = []
    idx_negA = []
    for i, a in enumerate(A):
        negA.append(i - a)
        idx_negA.append(i)
    cnt_negA = Counter(negA)
    negA_keys = sorted(cnt_negA.keys())
    ans = 0
    for i in range(N):
        if i + A[i] in cnt_negA:
            ans += cnt_negA[i + A[i]]
    print(ans)

from collections import Counter
import bisect


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    # divisors.sort()
    return divisors


if __name__ == "__main__":
    N = int(eval(input()))
    A = list(map(int, input().split()))
    negA = []
    for i, a in enumerate(A):
        negA.append(i - a)
    cnt_negA = Counter(negA)
    negA_keys = sorted(cnt_negA.keys())
    ans = 0
    for i in range(N):
        if i + A[i] in cnt_negA:
            ans += cnt_negA[i + A[i]]
    print(ans)

-    idx_negA = [] -        idx_negA.append(i)