#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
map<int,int>mp;
int n,a[N];
LL ans;

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