import std;

// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line = readln.split;
foreach (i,T;TList){T val=line[i].to!(T);Args[i]=val;}}
void dprint(TList...)(TList Args){debug{auto s=new string[](TList.length);
static foreach(i,a;Args) s[i]=text(a);s.map!(text).join(' ').writeln;}}
alias sread=()=>readln.chomp();enum MOD =10^^9+7;
alias PQueue(T,alias less="a<b") = BinaryHeap!(Array!T,less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long ans;
    auto diff = new long[](N);
    foreach (i; 0 .. N)
        diff[i] = (i + 1) - A[i];
    auto l = new long[][](2 * 10 ^^ 5 + 1);
    foreach (i; 0 .. N)
        if (diff[i] < l.length)
            l[diff[i]] ~= i;
    foreach (i; 0 .. N)
    {
        foreach (j; assumeSorted(l[A[i] + i + 1]).upperBound(i))
            if (i < j)
            {
                ans++;
            }
    }
    writeln(ans);
}
