using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
public static void Main() {
//ai - aj = j - i 这个问题可以转换为 ai - i = aj - j,所以只要知道每个数与它的下标差相等的数的个数就可以知道有多少个谐距下标对,计算下标对的对数的公式为 n(n-1)/2
int.TryParse(Console.ReadLine(), out int n);
string[] inputs = Console.ReadLine().Split(' ');
List<int> numLst = inputs.Select(int.Parse).ToList();
Dictionary<long, long> diffCount = new Dictionary<long, long>();
for(int i = 0; i < n; i++)
{
long diff = numLst[i] - i;
diffCount[diff] = diffCount.GetValueOrDefault(diff, 0) + 1;
}
ulong result = 0;
foreach(long count in diffCount.Values)
{
result += (ulong)(count * (count - 1) / 2);
}
Console.WriteLine(result);
}
}