#include<stdio.h>
#define ll long long
 
 
int main(void)
{
  ll n, i, j;
  scanf("%lld", &n);
  ll ans = 0;
  ll a[200001];
     for(i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }
 
       for(i = n - 1; i > 2; i--) {
        for(j = i - a[i] - 1; j >= 0; j--) {
            if(i - j == a[i] + a[j])
                ans++;
        }
    }
 
    printf("%lld", ans);
 
}