import sys

input = sys.stdin.readline





def RunLengthEncoding(list):

    dict = {}

    for i in list:

        if i in list(dict.keys()):

            dict[i] += 1

        else:

            dict[i] = 1

    return dict





n = int(eval(input()))

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

minus = [i-a[i] for i in range(n)]

plus = [i+a[i] for i in range(n)]

minus_cnt = RunLengthEncoding(minus)

plus_cnt = RunLengthEncoding(plus)



cnt=0

for i in minus_cnt:

    if i in plus_cnt:

        cnt += minus_cnt[i] * plus_cnt[i]

print(cnt)

import sys

input = sys.stdin.readline





def rle(list):

    dict = {}

    for i in list:

        if i in list(dict.keys()):

            dict[i] += 1

        else:

            dict[i] = 1

    return dict





n = int(eval(input()))

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

minus = rle([i-a[i] for i in range(n)])

plus = rle([i+a[i] for i in range(n)])



cnt = 0

for i in minus:

    if i in plus:

        cnt += minus[i] * plus[i]

print(cnt)

import sys

input = sys.stdin.readline


def RunLengthEncoding(list):
    dict = {}
    for i in list:
        if i in list(dict.keys()):
            dict[i] += 1
        else:
            dict[i] = 1
    return dict


n = int(eval(input()))
a = list(map(int, input().split()))
minus = [i - a[i] for i in range(n)]
plus = [i + a[i] for i in range(n)]
minus_cnt = RunLengthEncoding(minus)
plus_cnt = RunLengthEncoding(plus)
cnt = 0
for i in minus_cnt:
    if i in plus_cnt:
        cnt += minus_cnt[i] * plus_cnt[i]
print(cnt)

import sys

input = sys.stdin.readline


def rle(list):
    dict = {}
    for i in list:
        if i in list(dict.keys()):
            dict[i] += 1
        else:
            dict[i] = 1
    return dict


n = int(eval(input()))
a = list(map(int, input().split()))
minus = rle([i - a[i] for i in range(n)])
plus = rle([i + a[i] for i in range(n)])
cnt = 0
for i in minus:
    if i in plus:
        cnt += minus[i] * plus[i]
print(cnt)

-def RunLengthEncoding(list): +def rle(list): -minus = [i - a[i] for i in range(n)] -plus = [i + a[i] for i in range(n)] -minus_cnt = RunLengthEncoding(minus) -plus_cnt = RunLengthEncoding(plus) +minus = rle([i - a[i] for i in range(n)]) +plus = rle([i + a[i] for i in range(n)]) -for i in minus_cnt: -    if i in plus_cnt: -        cnt += minus_cnt[i] * plus_cnt[i] +for i in minus: +    if i in plus: +        cnt += minus[i] * plus[i]