# 直接抄题干然后双遍历复杂度太高只拿到一半分的版本
# import sys
# n = int(input())
# num_list = list(map(int,sys.stdin.readline().strip().split()))
# count = 0
# for i in range(n+1):
# for j in range(n+1):
# if i < j and (num_list[j-1]-num_list[i-1] == j - i ):
# count += 1
# print(count)
n = int(input())
num_list = list(map(int, input().split()))
count_dict = {}
# 遍历数组,计算每个 key = num - 下标
for idx in range(n):
num = num_list[idx]
key = num - idx
if key in count_dict:
count_dict[key] += 1
else:
count_dict[key] = 1
# 计算答案:每组相同的 key 能组成 k*(k-1)//2 对
ans = 0
for k in count_dict.values():
ans += k * (k - 1) // 2
print(ans)