# E - This Message Will Self-Distruct in 5s



from collections import Counter



n = int(eval(input()))

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

assert len(a) == n



# Ai + Aj == j - i

# Aj - j == -Ai - i



# Aj - j の各値の個数

diff = Counter(a[j] - (j+1) for j in range(n))



# 各Aiについて Aj - j == -Ai - i となるjの個数を数える

count = 0

for i in range(n):

    diff[a[i] - (i+1)] -= 1  # i自身を取り除く

    count += diff[-a[i] - (i+1)]



print(count)

# E - This Message Will Self-Distruct in 5s



from collections import Counter



n = int(eval(input()))

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

assert len(a) == n



# Aj - j の各値の個数

diff = Counter(a[j] - (j+1) for j in range(n))



# Aj - j == -Ai - i となる(i,j)の個数

count = sum(diff[-a[i] - (i+1)] for i in range(n))

print(count)

# E - This Message Will Self-Distruct in 5s
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
assert len(a) == n
# Ai + Aj == j - i
# Aj - j == -Ai - i
# Aj - j の各値の個数
diff = Counter(a[j] - (j + 1) for j in range(n))
# 各Aiについて Aj - j == -Ai - i となるjの個数を数える
count = 0
for i in range(n):
    diff[a[i] - (i + 1)] -= 1  # i自身を取り除く
    count += diff[-a[i] - (i + 1)]
print(count)

# E - This Message Will Self-Distruct in 5s
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
assert len(a) == n
# Aj - j の各値の個数
diff = Counter(a[j] - (j + 1) for j in range(n))
# Aj - j == -Ai - i となる(i,j)の個数
count = sum(diff[-a[i] - (i + 1)] for i in range(n))
print(count)

-# Ai + Aj == j - i -# Aj - j == -Ai - i -# 各Aiについて Aj - j == -Ai - i となるjの個数を数える -count = 0 -for i in range(n): -    diff[a[i] - (i + 1)] -= 1  # i自身を取り除く -    count += diff[-a[i] - (i + 1)] +# Aj - j == -Ai - i となる(i,j)の個数 +count = sum(diff[-a[i] - (i + 1)] for i in range(n))