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