Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import bisect
    n = int(input())
    l = sorted(list(map(int,input().split())))
    ans = 0
    for i in range(n-2):
        c = l[n-1-i]
        l_ = l[0:n-1-i]
        n_ = len(l_)
        for j in range(n_-1):
            l__ = l_[j+1:]
            b = bisect.bisect_left(l__,c+1-l_[j])
            ans += len(l__)-b
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L[j+1:],L[i]+L[j])
    cnt += insert
        
print(cnt)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
L = [int(L[i]) for i in range(len(L))]
L.sort(reverse=True)
tri = 0
for i in range(N):
  for j in range(i+1,N):
    tri += len([k for k in range(j+1,N) if L[i]-L[j] < L[k] < L[j]])
    
print(tri)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
L = [int(L[i]) for i in range(len(L))]
L.sort(reverse=True)
tri = 0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[k] + L[j] > L[i]:
        tri += 1
print(tri)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
L = [int(L[i]) for i in range(len(L))]

tri = 0
bar = [[L[i], L[j], L[k]] for i in range(N) for j in range(i+1,N) for k in range(j+1,N)]
for i in range(len(bar)):
  if bar[i][0] + bar[i][1] > bar[i][2]:
    if bar[i][0] + bar[i][2] > bar[i][1]:
      if bar[i][1] + bar[i][2] > bar[i][0]:
        tri += 1
print(tri)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
L = [int(L[i]) for i in range(len(L))]

tri = 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]:
        if L[j] < L[i] + L[k]:
          if L[k] < L[i] + L[j]:
            tri += 1
print(tri)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
L = [int(L[i]) for i in range(len(L))]

tri = 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[i] + L[k] and L[k] < L[i] + L[j]:
        tri += 1
print(tri)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0

import bisect
for i in range(N):
  for j in range(i+1,N-1):
    insert = bisect.bisect_left(L,L[i]+L[j]) -j -1
    cnt += insert
        
print(cnt)