#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

int L[200001];
int R[200001];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    int l = i + a;
    L[l]++;
    int r = ABS(i - a);
    if (L[r] > 0) {
      R[r]++;
    }
  }
  
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    // printf("%d %d %d\n", i, L[i], R[i]);
    sum += (long long)L[i] * R[i];
  }
  printf("%lld", sum);
  return 0;
}