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

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    min_sum = L[i]+L[j]
    more_than = bisect.bisect_left(L[j+1:], min_sum)
    ans += more_than
print(ans)

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

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
 
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ans = 0
for i in range(N):
  for j in range(i+1, N):
    min_sum = L[i]+L[j]
    more_than = bisect.bisect_left(L[j+1:], min_sum)
    ans += more_than
print(ans)


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

Buggy python submission (verdict: Runtime Error):
mport bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
 
 
def solve2():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            min_sum = L[i]+L[j]
            more_than = bisect.bisect_left(L[j+1:], min_sum)
            ans += more_than
    print(ans)
 
 
solve2()

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

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

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

ans=0
for i in range(0, n-2,1):
  for j in range(i+1,n-1,1):
    min_sum = L[i]+L[j]
    more_than = bisect.bisect_left(L[j+1:], min_sum)
    ans += more_than
print(ans)

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

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

n = int(input())
L =sorted([int(i) for i in input().split()])


#print(L)

ans=0
for i in range(0, n-2,1):
  for j in range(i+1,n-1,1):
    min_sum = L[i]+L[j]
    more_than = bisect.bisect_left(L[j+1:], min_sum)
    ans += more_than
print(ans)


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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L =sorted([int(i) for i in input().split()],reverse=True)

#print(L)

count=0
for i in range(0, n-2,1):
  c=L[i]
  x=0
  for j in range(i+1,n-1,1):
    b=L[j]
    for k in range(j+1,n,1):
      a=L[k]
      if a+b>c:
        count +=1
      else:
        if k == j+1:
          x=1
        break
    if x==1:
      break

print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L =sorted([int(i) for i in input().split()],reverse=True)

#print(L)

count=0
for i in range(0, n-2,1):
  x=0
  for j in range(i+1,n-1,1):
    for k in range(j+1,n,1):
      if (L[j] + L[k] > L[i]):
        count +=1
      else:
        if k == j+1:
          x=1
        break
    if x==1:
      break

print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L =sorted([int(i) for i in input().split()],reverse=True)

#print(L)

count=0
for i in range(0, n,1):
  x=0
  for j in range(i+1,n,1):
    for k in range(j+1,n,1):
      if (L[j] + L[k] > L[i]):
        count +=1
      else:
        if k == j+1:
          x=1
        break
    if x==1:
      break

print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L =sorted([int(i) for i in input().split()],reverse=True)

# print(L)

count=0
for i in range(0, n,1):
  x=0
  for j in range(i+1,n,1):
    for k in range(j+1,n,1):
      if (L[j] + L[k] > L[i]):
        count +=1
      else:
        if j == k+1:
          x=1
        break
    if x==1:
      break
print(count)

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

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L =sorted([int(i) for i in input().split()],reverse=True)

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

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

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

count=0
for i in range(0, len(L),1):
  for j in range(i+1,len(L),1):
    for k in range(j+1,len(L),1):
      if (L[i] + L[j] > L[k]) & (L[i] + L[k] > L[j]) & (L[j] + L[k] > L[i]):
        count +=1
print(count)

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