import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "c");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto a = aryread();
    long[long] R;
    foreach (i; iota(n))
    {
        if ((i - a[i]) in R)
            R[(i - a[i])]++;
        else
            R[(i - a[i])] = 1;
    }

    long cnt;
    foreach (i; iota(n))
    {
        cnt += (i + a[i]) in R ? R[i + a[i]] : 0;
    }
    cnt.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
