#include <stdio.h>

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

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