#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e7 + 10;
long long n,ans;
map<long long ,long long> a;
int main() {
	scanf("%lld",&n);
	for (int i = 1,x;i <= n;i++) {
		scanf("%lld",&x);
		a[i+x]++;
		ans += a[i-x];
	}
	printf("%lld",ans);
    return 0;
}