def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    from collections import defaultdict

    from itertools import combinations, permutations, accumulate, groupby, product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    import math

    #from math import gcd



    #inf = 10**17

    #mod = 10**9 + 7



    d = defaultdict(int)

    res = 0

    n = int(eval(input()))

    a = list(map(int, input().split()))

    for i in range(n-1, -1, -1):

        res += d[i+a[i]]

        d[i-a[i]] += 1

    print(res)



if __name__ == '__main__':

    main()
def main():

    import sys

    input = sys.stdin.readline

    sys.setrecursionlimit(10**7)

    from collections import Counter, deque

    from collections import defaultdict

    from itertools import combinations, permutations, accumulate, groupby, product

    from bisect import bisect_left,bisect_right

    from heapq import heapify, heappop, heappush

    import math

    #from math import gcd



    #inf = 10**17

    #mod = 10**9 + 7



    d = {}

    res = 0

    n = int(eval(input()))

    a = list(map(int, input().split()))

    for i in range(n-1, -1, -1):

        if i+a[i] in d:

            res += d[i+a[i]]

        if i-a[i] not in d:

            d[i-a[i]] = 1

        else:

            d[i-a[i]] += 1

    print(res)



if __name__ == '__main__':

    main()
def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    import math

    # from math import gcd
    # inf = 10**17
    # mod = 10**9 + 7
    d = defaultdict(int)
    res = 0
    n = int(eval(input()))
    a = list(map(int, input().split()))
    for i in range(n - 1, -1, -1):
        res += d[i + a[i]]
        d[i - a[i]] += 1
    print(res)


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left, bisect_right
    from heapq import heapify, heappop, heappush
    import math

    # from math import gcd
    # inf = 10**17
    # mod = 10**9 + 7
    d = {}
    res = 0
    n = int(eval(input()))
    a = list(map(int, input().split()))
    for i in range(n - 1, -1, -1):
        if i + a[i] in d:
            res += d[i + a[i]]
        if i - a[i] not in d:
            d[i - a[i]] = 1
        else:
            d[i - a[i]] += 1
    print(res)


if __name__ == "__main__":
    main()

-    d = defaultdict(int) +    d = {} -        res += d[i + a[i]] -        d[i - a[i]] += 1 +        if i + a[i] in d: +            res += d[i + a[i]] +        if i - a[i] not in d: +            d[i - a[i]] = 1 +        else: +            d[i - a[i]] += 1