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[long] l;
  long[long] r;
  for(long i=0; i<n; i++) {
    l[i+1+a[i]]++;
    r[i+1-a[i]]++;
  }
  long result = 0;
  foreach(k;l.byKey) {
    result += l[k]*r.get(k, 0);
  }
  result.writeln;
}
