#include <stdio.h>

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

    int A[N], A_max = 0;
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        if(A[i] > A_max) 
            A_max = A[i];   
    }

    int cnt = 0;
    for(int i = 0; i < N-1; i++){
        for(int j = A[i]+1; j <= A[i]+A_max && j <= N-1-i; j++){
            if(j == A[i]+A[i+j])
                cnt++;
        }
    }
    printf("%d\n", cnt);

    return 0;
}
