#include <stdio.h>
typedef long long ll;
int main() {
	int n, a[200000], list[200000] = {0}, cnt;
	ll ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		list[i - a[i]]++;
	}
	for (int i = 0; i < n; i++) {
		ans += list[a[i] + i];
	}
	printf("%lld\n", ans);
	return 0;
}