Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i in range(N-2):
    for j in range(i+1,N-1):
        k = j+1
        while k < N and l_new[i] + l_new[j] > l_new[k]:
            k += 1
        count += max(k-(j+1),0)
print(count)

Fixed submission:
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l,reverse=True)
for i in range(N-2):
    for j in range(i+1,N-1):
        for c in range(j+1,N):
            if l_new[i] >= l_new[j] + l_new[c]:
                break
            else:
                count += 1
print(count)

Fixed submission:
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
l = [int(i) for i in input().split()]
count = 0
for v in itertools.combinations(l,3):
    if max(v[0],v[1],v[2])*2 < sum(v):
        count += 1
print(count)

Fixed submission:
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
l = [int(i) for i in input().split()]
count = 0
for v in itertools.combinations(l,3):
    if v[0] < v[1] + v[2]:
        if v[1] < v[0] + v[2]:
            if v[2] < v[1] + v[0]:
                count += 1
print(count)

Fixed submission:
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
l = [int(i) for i in input().split()]
count = 0
for v in itertools.permutations(l,3):
    if v[0] < v[1] + v[2]:
        if v[1] < v[0] + v[2]:
            if v[2] < v[1] + v[0]:
                count += 1
print(count//6)

Fixed submission:
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)