#include <stdio.h>

#define N 200001
int r[2 * 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 = i - a[i];
            if (0 <= t && t < 2 * N) r[t]++;
            i++;
        } else n--;
    }
    for (int i = 1; i < n; i++)
        s += r[a[i] + i];
    printf("%d", s);
    return 0;
}