def main(n,a_):

  from collections import defaultdict

  lr=[[i+ai,i-ai] for i,ai in enumerate(a_)]

  rs=defaultdict(lambda:0)

  ls=defaultdict(lambda:0)

  ans=0

  for l,r in lr:

    rs[r]+=1

    ls[l]+=1

  for k in list(rs.keys()):

    ans+=rs[k]*ls[k]

  print(ans)

if __name__=='__main__':

  n=int(eval(input()))

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

  #n=200000

  #a_=[3 for _ in range(n)]

  main(n,a_)

n=int(eval(input()))

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

b=[]

c=[]

for i in range(n):

  b.append(a[i]-(i+1))

  c.append(-(a[i]+i+1))

from collections import defaultdict

#cnt_b=Counter(b)

cnt_c=defaultdict(int)

ans=0

for i in range(n):

  v=cnt_c[b[i]]

  ans+=v

  cnt_c[c[i]]+=1

print(ans)
def main(n, a_):
    from collections import defaultdict

    lr = [[i + ai, i - ai] for i, ai in enumerate(a_)]
    rs = defaultdict(lambda: 0)
    ls = defaultdict(lambda: 0)
    ans = 0
    for l, r in lr:
        rs[r] += 1
        ls[l] += 1
    for k in list(rs.keys()):
        ans += rs[k] * ls[k]
    print(ans)


if __name__ == "__main__":
    n = int(eval(input()))
    a_ = list(map(int, input().split()))
    # n=200000
    # a_=[3 for _ in range(n)]
    main(n, a_)

n = int(eval(input()))
a = list(map(int, input().split()))
b = []
c = []
for i in range(n):
    b.append(a[i] - (i + 1))
    c.append(-(a[i] + i + 1))
from collections import defaultdict

# cnt_b=Counter(b)
cnt_c = defaultdict(int)
ans = 0
for i in range(n):
    v = cnt_c[b[i]]
    ans += v
    cnt_c[c[i]] += 1
print(ans)

-def main(n, a_): -    from collections import defaultdict +n = int(eval(input())) +a = list(map(int, input().split())) +b = [] +c = [] +for i in range(n): +    b.append(a[i] - (i + 1)) +    c.append(-(a[i] + i + 1)) +from collections import defaultdict -    lr = [[i + ai, i - ai] for i, ai in enumerate(a_)] -    rs = defaultdict(lambda: 0) -    ls = defaultdict(lambda: 0) -    ans = 0 -    for l, r in lr: -        rs[r] += 1 -        ls[l] += 1 -    for k in list(rs.keys()): -        ans += rs[k] * ls[k] -    print(ans) - - -if __name__ == "__main__": -    n = int(eval(input())) -    a_ = list(map(int, input().split())) -    # n=200000 -    # a_=[3 for _ in range(n)] -    main(n, a_) +# cnt_b=Counter(b) +cnt_c = defaultdict(int) +ans = 0 +for i in range(n): +    v = cnt_c[b[i]] +    ans += v +    cnt_c[c[i]] += 1 +print(ans)