Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

import numpy as np

ans = 0
b = np.array(a[0])

for i in range(1,n):
    b-=1
    ans += np.count_nonzero(b == -a[i])
    b = np.append(b, a[i])

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

from collections import defaultdict
d = defaultdict(int)
ans = 0

for i in range(n):
    ans += d[i-a[i]]
    d[a[i]+i] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

dp = [[] for i in range(n)]
ans = 0

for i in range(n):
    b = i+a[i]
    if b < n:
        for j in range(b,n):
            if a[j] == j-b:
                ans += 1

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

from collections import defaultdict
d = defaultdict(int)
ans = 0

for i in range(n):
    ans += d[i-a[i]]
    d[a[i]+i] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

dp = [[] for i in range(n)]

for i in range(n):
    b = i+a[i]
    if b < n:
        for j in range(b,n):
            dp[j].append(j-b)
ans = 0
for i in range(n):
    ans += dp[i].count(a[i])

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

from collections import defaultdict
d = defaultdict(int)
ans = 0

for i in range(n):
    ans += d[i-a[i]]
    d[a[i]+i] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

dp = [[] for i in range(n)]

for i in range(n):
    b = i+a[i]
    if b < n:
        for j in range(b,n):
            dp[j].append(j-b)
ans = 0
for i in range(n):
    ans += dp[i].count(a[i])

print(ans)

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

from collections import defaultdict
d = defaultdict(int)
ans = 0

for i in range(n):
    ans += d[i-a[i]]
    d[a[i]+i] += 1

print(ans)