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

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        k = bisect_left(l[j+1:], shortest + second)
        ans += k

print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = np.sort(np.array(l))[::-1]

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        ans += np.count_nonzero(lsorted[second+1:] > (lsorted[longest] - lsorted[second]) )
print(ans)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        for third in lsorted[second+1:]:
            if lsorted[longest] - lsorted[second] - third >= 0:                
                break
            else:
                ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        se
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        for third in lsorted[second+1:]:
            if lsorted[longest] - lsorted[second] - third >= 0:                
                break
            else:
                ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

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

n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = np.sort(np.array(l))[::-1]

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        ans += np.count_nonzero(lsorted[second+1:] > (lsorted[longest] - lsorted[second]) )
print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):
        if lsorted[longest] - 2*lsorted[second] >= 0:
            break 
        for k in range(second+1, len(l)):
            if lsorted[longest] - lsorted[second] - lsorted[k] >= 0:                
                break
            else:
                ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list( map(int, input().split())) 
ans = 0

lsorted = sorted(l, reverse=True)

for longest in range(len(l)-2):

    for second in range(longest+1, len(l)):


        for k in range(second+1, len(l)):
            if lsorted[longest] - lsorted[second] - lsorted[k] >= 0:                
                break
            else:
                ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - 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

l3s = list(combinations(l,3))
for l3 in l3s:
    if abs(l3[1] - l3[2]) < l3[0] < (l3[1] + l3[2]):
        ans += 1
print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - 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

l3s = list(combinations(l,3))
for l3 in l3s:
    if abs(l3[1] - l3[2]) < l3[0] < (l3[1] + l3[2]):
        ans += 1
print(ans)

Fixed submission:
from bisect import bisect_left

n = int(input())
l = list( map(int, input().split())) 
ans = 0
l.sort()

for i in range(n-2):
    shortest = l[i]
    for j in range(i+1, n-1):
        second = l[j]
        # このスライスしたやつと地味にTLEになる...
        # k = bisect_left(l[j], shortest + second)
        # ans += k

        k = bisect_left(l, shortest + second)
        ans += k - j - 1

print(ans)