Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
i_Ai = [0] * (max(j_Aj)+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=max(j_Aj):
        i_Ai[j + a[j - 1]] += 1
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]
i_Ai = [0] * (max(j_Aj)+1)

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=max(j_Aj):
        i_Ai[j + a[j - 1]] += 1
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]
i_Ai = [0] * (max(a)+n+1)

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    i_Ai[j + a[j - 1]] += 1
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]
i_Ai = [0] * (10 ** 9 + 2 * 10 ** 5)

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    i_Ai[j + a[j - 1]] += 1
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]


j_Aj=[0]
i_Ai=[0]*(10**9+2*10**5)

for j,aj in enumerate(a):
    j_Aj.append(j+1-aj)
ans=0
for j,j_aj in enumerate(j_Aj):
    if j==0:
        continue
    if j_aj>=2:
        ans+=i_Ai[j_aj]
    i_Ai[j+a[j-1]]+=1
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]


j_Aj=[0]
i_Ai=[0]*(10**9+2*10**5)

for j,aj in enumerate(a):
    j_Aj.append(j+1-aj)
ans=0
for j,j_aj in enumerate(j_Aj):
    if j==0:
        continue
    if j_aj>=2:
        ans+=i_Ai[j_aj]
    i_Ai[j+a[j-1]]+=1
print(ans)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]



def count(num_list):
    l=len(num_list)
    num_array=np.array(num_list[1:])
    check=np.array(range(1,l))-num_list[0]
    ans=num_array-check
    return l-np.count_nonzero(ans)-1
ans=0
for i in range(0,n-1):
    check_list=a[i:]
    ans+=count(check_list)
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

j_Aj = [0]

for j, aj in enumerate(a):
    j_Aj.append(j + 1 - aj)
maxj=max(j_Aj)
i_Ai = [0] * (maxj+1)
ans = 0
for j, j_aj in enumerate(j_Aj):
    if j == 0:
        continue
    if j_aj >= 2:
        ans += i_Ai[j_aj]
    if j + a[j - 1]<=maxj:
        i_Ai[j + a[j - 1]] += 1
print(ans)