using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace ABC166
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            new ABC_E();
        }
    }
    public class ABC_A
    {
        public ABC_A()
        {
            var s = Ex.Read;

            var str = s == "ABC" ? "ARC" : "ABC";
            str.Cw();
        }
    }
    public class ABC_B
    {
        public ABC_B()
        {
            var l = Ex.ReadIntArray();
            // N 人のすぬけ君  K 種類のお菓子
            var n = (int)l[0];
            var k = (int)l[1];

            // お菓子を1つも持っていない
            bool[] ans = new bool[n];

            for (int i = 0; i < k; i++)
            {
                var ii = Ex.ReadInt;
                var l2 = Ex.ReadIntArray();
                foreach (var v in l2) ans[v - 1] = true;
            }
            ans.Where(v => !v).Count().Cw();
        }
    }
    public class ABC_C
    {
        public ABC_C()
        {
            var l = Ex.ReadLongArray();
            // N 個の展望台があり、展望台 i の標高は H i です。  M 本の道
            // 道jは展望台Ajと展望台Bjを結んでいます
            var n = l[0];
            var m = l[1];

            var h = Ex.ReadLongArray();

            //展望台 i から一本の道を使って辿り着ける どの展望台よりも展望台 i の方が標高が高い
            //展望台 i から一本の道を使って辿り着ける 展望台が存在しない場合
            bool[] ans = new bool[n];

            for (int i = 0; i < m; i++)
            {
                var lm = Ex.ReadLongArray();
                var a = lm[0] - 1;
                var b = lm[1] - 1;
                if (h[a] <= h[b]) ans[a] = true;
                if (h[a] >= h[b]) ans[b] = true;
            }
            ans.Where(v => !v).Count().Cw();
        }
    }
    public class ABC_D
    {
        long x;
        public ABC_D()
        {
            x = Ex.ReadLong;
            if (0 == x)
            {
                $"0 0".Cw();
                return;
            }

            long[] arr = new long[90];

            //for (long i = 0; true; i++)
            //{
            //    if (i * i * i * i * i > 2 * 1000000000)
            //    {
            //        i.Cw();
            //        break;
            //    }
            //}
            for (long i = 0; i < 90; i++)
            {
                arr[i] = i * i * i * i * i;
                if (arr[i] == x)
                {
                    $"0 -{i}".Cw();
                    return;
                }
            }
            for (long j = 0; j < 90; j++)
            {
                for (long k = j; (arr[j] + arr[k]) <= x && k < 88; k++)
                {
                    //$"{j} -{k}".Cw();
                    if (arr[j] + arr[k] == x)
                    {
                        $"{j} -{k}".Cw();
                        return;
                    }
                }
                for (long k = j; k > 0 && (arr[j] - arr[k]) <= x; k--)
                {
                    // $"{j} {k}".Cw();
                    if (arr[j] - arr[k] == x)
                    {
                        $"{j} {k}".Cw();
                        return;
                    }
                }
            }
        }
    }
    public class ABC_E
    {
        public ABC_E()
        {
            long n = Ex.ReadLong;
            var l = Ex.ReadLongArray();
            long ans = 0;
            long[] arr = new long[n];
            for (long i = 0; i < n; i++)
            {
                if (i - l[i] >= 0)
                    arr[i - l[i]]++;
            }
            for (long i = 0; i < n; i++)
            {
                if (i + l[i] < n) ans += arr[i + l[i]];
            }
            ans.Cw();
        }
    }
    public class ABC_F
    {
        public ABC_F()
        {
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }

        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static string yesno(this bool b) { return b ? "yes" : "no"; }
        public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        public static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 40092