#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(){
  int N, A[200005], ans = 0, num, num2;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%d", A + i);
  for (int i = 0; i < N; i++) {
    num = i - A[i];
    num2 = num / 2
    for (int j = 0; j <= num2; j++) {
      if (num - j == A[j]) ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
