#include <stdio.h>

#define N 200001
int r[N] = {0};

int main() {
    int n, s = 0, a[N], t;
    scanf("%d", &n);
    for (int i = 1; i <= n;) {
        scanf("%d", &a[i]);
        if (a[i] < N) {
            t = a[i] - i;
            if (t <= 0) r[-t]++;
            i++;
        } else n--;
    }
    for (int i = 1; i < n; i++) {
        s += r[a[i] + i];
    }
    printf("%d", s);
    return 0;
}
