#include <stdio.h>

int main() {
    int n, s = 0, a[200001];
    scanf("%d", &n);
    for (int i = 1; i <= n;) {
        scanf("%d", &a[i]);
        a[i] < 200001 ? i++ : n--;
    }
    for (int i = 1; i < n; i++) {
        for (int j = i + a[i] + 1, k = 1; j <= n; j++, k++)
            if (a[j] == k) s++;
    }
    printf("%d", s);
    return 0;
}
