# -*- coding: utf-8 -*-

"""

Created on Sun May  3 21:27:48 2020

"""



import sys

import numpy as np

import itertools



sys.setrecursionlimit(10 ** 9)

#def input():

#    return sys.stdin.readline()[:-1]

mod = 10**9+7



N = int(eval(input()))

#X, Y = map(int,input().split())

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



A = np.array(A)

B = np.arange(N)



x = A - B

y = A + B



x.sort()

y.sort()



ans = 0

i, j = 0, N - 1

#pre = 10**10

x1, y1 = 0, 0

while i < N and j >= 0:

    if -x[i] < y[j]:

        j -= 1

    elif -x[i] > y[j]:

        i += 1

    else:

        x1,y1 = 1, 1

        pre = y[j]

        while pre == -x[i+1]:

            x1 += 1

            i += 1

#            print('x',pre,x1)

        while pre == y[j-1]:

            y1 += 1

            j -= 1

#            print('y',pre,y1)

        i += 1

        j -= 1

        ans += x1 * y1

#        print()

#    print(i,j,x[i],y[j],x1,y1,ans)

print(ans)
# -*- coding: utf-8 -*-

"""

Created on Sun May  3 21:27:48 2020

"""



import sys

import numpy as np

import itertools



sys.setrecursionlimit(10 ** 9)



N = int(eval(input()))

A = np.array(list(map(int,input().split())))

B = np.arange(N)

x = B - A

y = B + A



x = x[x>0]

y = y[y<N]

x_count = np.bincount(x, minlength = N)

y_count = np.bincount(y, minlength = N)



ans = np.sum(x_count * y_count)



print(ans)
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:27:48 2020
"""
import sys
import numpy as np
import itertools

sys.setrecursionlimit(10**9)
# def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9 + 7
N = int(eval(input()))
# X, Y = map(int,input().split())
A = list(map(int, input().split()))
A = np.array(A)
B = np.arange(N)
x = A - B
y = A + B
x.sort()
y.sort()
ans = 0
i, j = 0, N - 1
# pre = 10**10
x1, y1 = 0, 0
while i < N and j >= 0:
    if -x[i] < y[j]:
        j -= 1
    elif -x[i] > y[j]:
        i += 1
    else:
        x1, y1 = 1, 1
        pre = y[j]
        while pre == -x[i + 1]:
            x1 += 1
            i += 1
        #            print('x',pre,x1)
        while pre == y[j - 1]:
            y1 += 1
            j -= 1
        #            print('y',pre,y1)
        i += 1
        j -= 1
        ans += x1 * y1
#        print()
#    print(i,j,x[i],y[j],x1,y1,ans)
print(ans)

# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:27:48 2020
"""
import sys
import numpy as np
import itertools

sys.setrecursionlimit(10**9)
N = int(eval(input()))
A = np.array(list(map(int, input().split())))
B = np.arange(N)
x = B - A
y = B + A
x = x[x > 0]
y = y[y < N]
x_count = np.bincount(x, minlength=N)
y_count = np.bincount(y, minlength=N)
ans = np.sum(x_count * y_count)
print(ans)

-# def input(): -#    return sys.stdin.readline()[:-1] -mod = 10**9 + 7 -# X, Y = map(int,input().split()) -A = list(map(int, input().split())) -A = np.array(A) +A = np.array(list(map(int, input().split()))) -x = A - B -y = A + B -x.sort() -y.sort() -ans = 0 -i, j = 0, N - 1 -# pre = 10**10 -x1, y1 = 0, 0 -while i < N and j >= 0: -    if -x[i] < y[j]: -        j -= 1 -    elif -x[i] > y[j]: -        i += 1 -    else: -        x1, y1 = 1, 1 -        pre = y[j] -        while pre == -x[i + 1]: -            x1 += 1 -            i += 1 -        #            print('x',pre,x1) -        while pre == y[j - 1]: -            y1 += 1 -            j -= 1 -        #            print('y',pre,y1) -        i += 1 -        j -= 1 -        ans += x1 * y1 -#        print() -#    print(i,j,x[i],y[j],x1,y1,ans) +x = B - A +y = B + A +x = x[x > 0] +y = y[y < N] +x_count = np.bincount(x, minlength=N) +y_count = np.bincount(y, minlength=N) +ans = np.sum(x_count * y_count)