#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n;
long long ans;
map <int,int> m;

int main()
{
    
	scanf("%d",&n);
    int a[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ans+=m[a[i]-i];
		m[-a[i]-i]++;
	}

	cout<<ans;
}
