#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
#define G() Cr = getchar()
#define LL long long
int Xr; char Cr;
inline int rd() {
	Xr = 0, G();
	while(Cr < '0' || Cr > '9') G();
	while(Cr >= '0' && Cr <= '9') Xr = (Xr<<1) + (Xr<<3) + (Cr&15), G();
	return Xr;
}
#define MAX_N 200005
int n;
int va[MAX_N];
map<int,int>mp;
LL ans;
int main() { 
	n = rd();
	for(int i = 1; i <= n; i++) {
		va[i] = rd();
		ans += mp[i-va[i]];
		mp[va[i]+i]++;
	}
	cout<<ans;
}