Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

ai = []
ans = 0

for i in range(n):
    ai.append(i + l[i])

for j in range(n):
    ans = ans + ai.count(j - l[j])

print(ans)


Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

ai = []
aj = []
ans = 0

for i in range(n):
    ai.append(i + l[i])

for j in range(n):
    aj.append(j - l[j])

ai.sort()
aj.sort()

s = min(ai)
e = max(aj)

# print(ai)
# print(aj)
# print(s)
# print(e)

for x in range(n):
    ans = ans + aj.count(ai[x])
    if x >= e+1:
        break
    
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

ai = []
aj = []
ans = 0
aiajmin = -9999999


for i in range(n):
    ai.append(i+l[i])

for j in range(n):
    aj.append(j-l[j])

#print(ai)
#print(aj)
    
aiajmin = min(max(ai),max(aj))
aiajmax = max(min(ai),min(aj))
ai.sort()
aj.sort()

for x in range(n):
    if(ai[x] <= aiajmin and ai[x] >= aiajmax):
        ans = ans + aj.count(ai[x])
    else:
        break
    
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

ai = []
aj = []
ans = 0
aiajmin = -9999999


for i in range(n):
    ai.append(i+l[i])

for j in range(n):
    aj.append(j-l[j])

#print(ai)
#print(aj)
    
aiajmin = min(max(ai),max(aj))
ai.sort()
aj.sort()

for x in range(n):
    if(ai[x] <= aiajmin):
        ans = ans + aj.count(ai[x])
    else:
        break
    
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

ai = []
aj = []
ans = 0

for i in range(n):
    ai.append(i+l[i])

for j in range(n):
    aj.append(j-l[j])

#print(ai)
#print(aj)

for x in range(n):
    ans = ans + aj.count(ai[x])
    
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
count = 0
n = int(input())
l = list(map(int,input().split()))

#for i,j in enumerate(l):

for i in range(n):
    v = i + l[i]
    j = i + 1
    while(j < n):
        if(v == j-l[j]):
            count = count + 1
            #print(v,j-l[j])
        j = j + 1

print(count)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

max = max(l) * 2

ans = 0

for i in range(n):
    j = i + 1
    if l[i] < n:
        while(j < n and j <= i+max):
    
            if abs(j- i) == l[i]+l[j]:
                ans = ans + 1
                #print(abs(j-i),l[i]+l[j],i,j)
            j = j + 1
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
ans = 0
n = int(input())
a = list(map(int,input().split()))

amax = max(a)
amin = min(a)

max = amax * 2

'''
if amin * 2 < n:
    print(0)
'''  
    
for i in range(n):
    j = i + 1 + amin

    while(j < n and j <= i + max):
        if abs(j - i) == a[i] + a[j]:
            ans = ans + 1
        j = j + 1

print(ans)


Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

max = max(l) * 2

ans = 0

for i in range(n):
    j = i + 1

    while(j < n and j <= i+max):

        if abs(j- i) == l[i]+l[j]:
            ans = ans + 1
            #print(abs(j-i),l[i]+l[j],i,j)
        j = j + 1
print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))

a=[]
b={}
ans=0

for i in range(n):
    a.append(i+l[i])
    b[i-l[i]] = b.get(i-l[i],0) + 1

for av in a:
    ans = ans + b.get(av,0)

print(ans)