from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

from bisect import bisect_left,bisect_right 

import sys,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

a = inpl()

sa = defaultdict(int)

for i,x in enumerate(a):

    sa[(i+1)-x] += 1

res = 0

for i,x in enumerate(a):

    res += sa[i+1+x]

print(res)
from collections import Counter,defaultdict,deque

from heapq import heappop,heappush

from bisect import bisect_left,bisect_right 

import sys,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

a = inpl()

d = defaultdict(int)

for i,x in enumerate(a):

    d[i+1-x] += 1

res = 0

for i,x in enumerate(a):

    res += d[i+1+x]

print(res)
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
a = inpl()
sa = defaultdict(int)
for i, x in enumerate(a):
    sa[(i + 1) - x] += 1
res = 0
for i, x in enumerate(a):
    res += sa[i + 1 + x]
print(res)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
import sys, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
a = inpl()
d = defaultdict(int)
for i, x in enumerate(a):
    d[i + 1 - x] += 1
res = 0
for i, x in enumerate(a):
    res += d[i + 1 + x]
print(res)

-from heapq import heappop, heappush, heapify +from heapq import heappop, heappush -sa = defaultdict(int) +d = defaultdict(int) -    sa[(i + 1) - x] += 1 +    d[i + 1 - x] += 1 -    res += sa[i + 1 + x] +    res += d[i + 1 + x]