#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int number[N], h[N];
    for(int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }

    int c, d;
    int count = 0;
    for(int i = 0; i < N; i++) {
        number[i] = i;
        for(int j = 0; j < N; j++) {
            c = number[i] - number[j];
            d = h[i] + h[j];
            if(d == abs(c)) {
                count++;
            }
        }
    }

    printf("%d\n", count);
    return 0;
}