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

const int N = 2e5 + 5;
typedef long long ll;

map <int, int> cnt;
int n, a[N];
ll ans;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		ans += cnt[a[i] - i];
		cnt[-(a[i] + i)]++;
	}
	cout<<ans<<endl;
	return 0;
}