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

typedef struct {
    int         idx;
    long long   h;
} Human;

static int compare_human (const void *a, const void *b) {
    Human *a_ = (Human*)a, *b_ = (Human*)b;
    if ( a_->h > b_->h )
        return 1;
    if ( a_->h < b_->h )
        return -1;
    return 0;
}

int main (void) {
    int N;
    scanf("%d", &N);
    Human participants[N+1];
    for ( int i=1; i<=N; i++ ) {
        participants[i].idx = i;
        scanf("%lld", &participants[i].h);
    }

    qsort(&participants[1], N, sizeof(Human), compare_human);

    long long ans = 0;
    for ( int i=1; i<=N; i++ ) {
        for ( int j=i+1; j<=N; j++ ) {
            if ( participants[j].h > N )
                break;
            if ( participants[i].h + participants[j].h > N )
                break;
            if ( participants[i].h + participants[j].h ==
                 abs(participants[i].idx - participants[j].idx) ) {
                ans++;
            }
        }
    }

    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}
