Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()

res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L[j+1:], L[i]+L[j])
        res += idx

print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L[j+1:], L[i]+L[j])
        res += idx
print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L[j+1:], L[i]+L[j])
        res += idx
print(res

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L = L.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L[j+1:], L[i]+L[j])
        res += idx
print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split())).sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L[j+1:], L[i]+L[j])
        res += idx
print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from bisect import bisect_left

def comb_list(seq:list, n:int):
    return list(itertools.combinations(seq, n))

N = int(input())
L = sorted(list(map(int, input().split())))

res = 0
for (i, j) in list(comb_list(list(range(N-1)), 2)):
    res += bisect_left(L[j+1:],L[i]+L[j])
print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L[j+1:], L[i]+L[j])
        res += idx

print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())

L = list(map(int, input().split()))
L = sorted(L)

res = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        npl = np.array(L[j+1:])
        res += len(npl[npl<L[i]+L[j]])

print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = list(map(int, input().split()))
l = sorted(l)

res = 0
for i in range(n):
    for j in range(i, n):
        if i!=j:
            ab = l[i]+l[j]
            for k in range(j, n):
                if i!=k and j!=k and l[k] < ab:
                    res += 1
                else:
                    continue

print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

l = list(map(int, input().split()))
l = sorted(l)

res = 0
for i in range(n):
    for j in range(i, n):
        if i!=j:
            ab = l[i]+l[j]
            for k in range(j, n):
                if i!=k and j!=k and l[k] < ab:
                    res += 1
print(res)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect_left(L, L[i]+L[j])
        res += max(0,idx-(j+1))
print(res)