import bisect

import copy

import heapq

import math

import sys

from collections import *

from functools import lru_cache

from itertools import accumulate, combinations, permutations, product

def input():

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

def ruiseki(lst):

    return [0]+list(accumulate(lst))

sys.setrecursionlimit(500000)

mod=pow(10,9)+7

al=[chr(ord('a') + i) for i in range(26)]

direction=[[1,0],[0,1],[-1,0],[0,-1]]



n=int(eval(input()))

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



dic=defaultdict(int)

ans=0

for i in range(n):

    ans+=dic[i-a[i]]

    dic[a[i]+i]+=1

print(ans)
import bisect

import copy

import heapq

import math

import sys

from collections import *

from functools import lru_cache

from itertools import accumulate, combinations, permutations, product

def input():

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

def ruiseki(lst):

    return [0]+list(accumulate(lst))

sys.setrecursionlimit(500000)

mod=pow(10,9)+7

al=[chr(ord('a') + i) for i in range(26)]

direction=[[1,0],[0,1],[-1,0],[0,-1]]



n=int(eval(input()))

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



dic={}

ans=0

for i in range(n):

    if i-a[i] in dic:

        ans+=dic[i-a[i]]

    if a[i]+i in dic:

        dic[a[i]+i]+=1

    else:

        dic[a[i]+i]=1

print(ans)
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product


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


def ruiseki(lst):
    return [0] + list(accumulate(lst))


sys.setrecursionlimit(500000)
mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
n = int(eval(input()))
a = list(map(int, input().split()))
dic = defaultdict(int)
ans = 0
for i in range(n):
    ans += dic[i - a[i]]
    dic[a[i] + i] += 1
print(ans)

import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product


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


def ruiseki(lst):
    return [0] + list(accumulate(lst))


sys.setrecursionlimit(500000)
mod = pow(10, 9) + 7
al = [chr(ord("a") + i) for i in range(26)]
direction = [[1, 0], [0, 1], [-1, 0], [0, -1]]
n = int(eval(input()))
a = list(map(int, input().split()))
dic = {}
ans = 0
for i in range(n):
    if i - a[i] in dic:
        ans += dic[i - a[i]]
    if a[i] + i in dic:
        dic[a[i] + i] += 1
    else:
        dic[a[i] + i] = 1
print(ans)

-dic = defaultdict(int) +dic = {} -    ans += dic[i - a[i]] -    dic[a[i] + i] += 1 +    if i - a[i] in dic: +        ans += dic[i - a[i]] +    if a[i] + i in dic: +        dic[a[i] + i] += 1 +    else: +        dic[a[i] + i] = 1