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

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        l_long = l[j+1:n]
        bis = bisect.bisect_right(l_long, short_2hen-1)
        count += bis
print(count)


Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)

Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        l_long = l[j+1:n]
        bis = bisect.bisect_right(l_long, short_2hen-1)
        count += bis
        print(l_long)
        print(bis)
print(count)


Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
count = 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]:
                count += 1
print(count)


Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
count = 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]:
                count += 1
print(count)


Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
count = 0
for i in range(n-2):
    for j in range(n-i-2):
        L = l[i]
        M = l[i+j+1]
        joken = L - M + 1
        for k in range(len(l[i+j+2::])):
            nl = l[i+j+2::]
            if nl[k] >= joken:
                count += 1
print(count)


Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
count = 0
for i in range(n-2):
    for j in range(n - i - 2):
        for k in range(n - i - j - 2):
            hen = []
            hen.append(l[i])
            hen.append(l[i+j+1])
            hen.append(l[i+j+k+2])
            if hen[0] < hen[1] + hen[2]:
                count += 1
print(count)


Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        short_2hen = l[i] + l[j]
        bis = bisect.bisect_left(l, short_2hen)
        count += bis - j - 1
print(count)