Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

cnt = 0
for i in range(N):
    c = Counter(A2[i+1:])
    cnt += c[A1[i]]

print(cnt)

Fixed submission:
from collections import Counter
# import sys

# input = sys.stdin.readline

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

c = Counter(A2)

cnt = 0
for i in range(N):
    cnt += c[A1[i]]

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

cnt = 0
for i in range(N):
    c = Counter(A2[i+1:])
    cnt += c[A1[i]]

print(cnt)

Fixed submission:
from collections import Counter
# import sys

# input = sys.stdin.readline

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

c = Counter(A2)

cnt = 0
for i in range(N):
    cnt += c[A1[i]]

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + (i+1)
    A2[i] = (i+1) - A[i]

cnt = 0
for i in range(N):
    cnt += Counter(A2[i:])[A1[i]]

print(cnt)

Fixed submission:
from collections import Counter
# import sys

# input = sys.stdin.readline

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

c = Counter(A2)

cnt = 0
for i in range(N):
    cnt += c[A1[i]]

print(cnt)

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

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + (i+1)

for j in range(N):
    A2[j] = (j+1) - A[j]

cnt = 0
for i in range(N):
    cnt += A2[i:].count(A1[i])

print(cnt)

Fixed submission:
from collections import Counter
# import sys

# input = sys.stdin.readline

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

c = Counter(A2)

cnt = 0
for i in range(N):
    cnt += c[A1[i]]

print(cnt)

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

cnt = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] + A[j] == j-i:
            cnt += 1
print(cnt)

Fixed submission:
from collections import Counter
# import sys

# input = sys.stdin.readline

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

c = Counter(A2)

cnt = 0
for i in range(N):
    cnt += c[A1[i]]

print(cnt)

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

cnt = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] + A[j] == j-i:
            cnt += 1
print(cnt)

Fixed submission:
from collections import Counter
# import sys

# input = sys.stdin.readline

N = int(input())
A = [int(a) for a in input().split()]

A1 = [0]*N
A2 = [0]*N

for i in range(N):
    A1[i] = A[i] + i
    A2[i] = i - A[i]

c = Counter(A2)

cnt = 0
for i in range(N):
    cnt += c[A1[i]]

print(cnt)