#include <stdio.h>

int main() {
	int n, a[200000], ans = 0;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (j - i == a[i] + a[j])
				ans++;
		}
	}

	printf("%d", ans);
}