#include <stdio.h>

#define int64 long long

int main()
{
  int64 nn;
  scanf("%lld", &nn);
  int64 aa[nn][2], tmp, cnt = 0;
  for(int64 ii = 0;ii < nn;ii++)
  {
    scanf("%lld", &tmp);
    if(tmp <= 200000)
    {
      aa[cnt][0] = ii;
      aa[cnt][1] = tmp;
      cnt++;
    }
  }
  int64 ans = 0;
  for(int64 ii = 0;ii < cnt - 1;ii++)
  {
    for(int64 jj = ii + 1;jj < cnt;jj++)
    {
      if(aa[jj][0] - aa[ii][0] == aa[jj][1] + aa[ii][1])
      {
        ans++;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}