Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int,input().split())))
table = [[0 for _ in range(N)] for _ in range(N)]
ans = 0
for i in range(1,N-1):
  for j in range(i):
    for k in range(i+1,N):
      if L[i]+L[j]<=L[k]:break 
      elif L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
        ans += 1
print(ans)

Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int,input().split())))
table = [[0 for _ in range(N)] for _ in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i]+L[j]<=L[k]:break 
      elif L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
        ans += 1
print(ans)

Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int,input().split())))
table = [[0 for _ in range(N)] for _ in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i]+L[j]>L[k] and L[j]+L[k]>L[i] and L[k]+L[i]>L[j]:
        ans += 1
print(ans)

Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for ai in range(N):
  for bi in range(ai+1,N):
    for ci in range(bi+1,N):
      if L[ci] < L[ai] + L[bi]:      
        ans += 1
      else:break
print(ans)


Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for idx in range(2,N):
  if L[idx] < L[idx-1] + L[idx-2]:
    for cmb in combinations(L[:idx],2):
      if L[idx] < sum(cmb): ans += 1
print(ans)

Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for ai in range(N):
  for bi in range(ai+1,N):
    for ci in range(bi+1,N):
      if L[ci] < L[ai] + L[bi]:
        ans += 1
print(ans)

Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
L = list(map(int,input().split()))
ans = 0
for cmb in combinations(L,3):
  max_val = max(cmb)
  if 2*max_val < sum(cmb): ans += 1
print(ans)

Fixed submission:
import bisect 
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    idx = bisect.bisect(L,L[i]+L[j]-1)
    ans += idx-j-1
print(ans)