def e_this_message_will_self_destruct_in_5s():

    from bisect import bisect_left

    N = int(eval(input()))

    A = [int(i) for i in input().split()]



    add = [j + a for j, a in enumerate(A, 1)]

    diff = sorted([k - a for k, a in enumerate(A, 1)])

    ans = 0

    for p in add:

        ans += bisect_left(diff, p + 1) - bisect_left(diff, p)

    return ans



print((e_this_message_will_self_destruct_in_5s()))
def e_this_message_will_self_destruct_in_5s():

    from collections import Counter

    N = int(eval(input()))

    A = [int(i) for i in input().split()]



    add = [j + a for j, a in enumerate(A, 1)]

    diff = [k - a for k, a in enumerate(A, 1)]

    count = Counter(diff)

    return sum([count[p] for p in add])



print((e_this_message_will_self_destruct_in_5s()))
def e_this_message_will_self_destruct_in_5s():
    from bisect import bisect_left

    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    add = [j + a for j, a in enumerate(A, 1)]
    diff = sorted([k - a for k, a in enumerate(A, 1)])
    ans = 0
    for p in add:
        ans += bisect_left(diff, p + 1) - bisect_left(diff, p)
    return ans


print((e_this_message_will_self_destruct_in_5s()))

def e_this_message_will_self_destruct_in_5s():
    from collections import Counter

    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    add = [j + a for j, a in enumerate(A, 1)]
    diff = [k - a for k, a in enumerate(A, 1)]
    count = Counter(diff)
    return sum([count[p] for p in add])


print((e_this_message_will_self_destruct_in_5s()))

-    from bisect import bisect_left +    from collections import Counter -    diff = sorted([k - a for k, a in enumerate(A, 1)]) -    ans = 0 -    for p in add: -        ans += bisect_left(diff, p + 1) - bisect_left(diff, p) -    return ans +    diff = [k - a for k, a in enumerate(A, 1)] +    count = Counter(diff) +    return sum([count[p] for p in add])