from collections import Counter





def main():

    n = int(eval(input()))

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

    b = []

    c = []

    for i in range(n):

        b.append(a[i] + i + 1)

        c.append(i + 1 - a[i])

    b = list(Counter(b).items())

    c = Counter(c)

    answer = 0

    for i, n in b:

        if i in c:

            answer += n * c[i]

    print(answer)





if __name__ == '__main__':

    main()



def main():

    n = int(eval(input()))

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

    b = []

    c = {}

    answer = 0

    for i in range(n):

        b.append(a[i] + i + 1)

        tmp = -a[i] + i + 1

        if tmp in c:

            c[tmp] += 1

        else:

            c[tmp] = 1

    for i in range(n):

        if b[i] in c:

            answer += c[b[i]]

    print(answer)





if __name__ == '__main__':

    main()



from collections import Counter


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    b = []
    c = []
    for i in range(n):
        b.append(a[i] + i + 1)
        c.append(i + 1 - a[i])
    b = list(Counter(b).items())
    c = Counter(c)
    answer = 0
    for i, n in b:
        if i in c:
            answer += n * c[i]
    print(answer)


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    b = []
    c = {}
    answer = 0
    for i in range(n):
        b.append(a[i] + i + 1)
        tmp = -a[i] + i + 1
        if tmp in c:
            c[tmp] += 1
        else:
            c[tmp] = 1
    for i in range(n):
        if b[i] in c:
            answer += c[b[i]]
    print(answer)


if __name__ == "__main__":
    main()

-from collections import Counter - - -    c = [] +    c = {} +    answer = 0 -        c.append(i + 1 - a[i]) -    b = list(Counter(b).items()) -    c = Counter(c) -    answer = 0 -    for i, n in b: -        if i in c: -            answer += n * c[i] +        tmp = -a[i] + i + 1 +        if tmp in c: +            c[tmp] += 1 +        else: +            c[tmp] = 1 +    for i in range(n): +        if b[i] in c: +            answer += c[b[i]]