import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

alias tuple = Tuple!(long,long,long);

void main() {
  long n = readln.chomp.to!long;
  long[] a = readln.chomp.split.to!(long[]);
  long count = 0;
  for(long j=2; j<n; j++) {
    long r = j+1-a[j];
    if(r>=3) {
      for(long i=0; i<j; i++) {
        if(i+1+a[i]==r) count++;
      }
    }
  }
  count.writeln;
}
