Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i, N):
        if i == j:
            continue
        b = l[j]
        l2 = l[j+1:]
        start = bisect_right(l2, b-a)
        end = bisect_left(l2, a+b)
        cnt += len(l2[start:end])
print(cnt)

Fixed submission:
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[j+1:], a+b)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i, N):
        if i == j:
            continue
        b = l[j]
        l2 = l[j+1:]
        start = bisect_right(l2, b-a)
        end = bisect_left(l2, a+b)
        cnt += len(l2[start:end])
print(cnt)

Fixed submission:
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[j+1:], a+b)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i, N):
        if i == j:
            continue
        b = l[j]
        l2 = l[:i] + l[i+1:j] + l[j+1:]
        start = bisect_right(l2, b-a)
        end = bisect_left(l2, a+b)
        cnt += len(l2[start:end])
print(cnt//3)

Fixed submission:
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[j+1:], a+b)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = sorted(list(map(int, input().split())))

from bisect import bisect_left, bisect_right

kumi = set()
for i in range(N):
    a = l[i]
    for j in range(i, N):
        if i == j:
            continue
        b = l[j]
        start = bisect_right(l, max(a,b)-min(a,b))
        end = bisect_left(l, a+b)
        for c in l[start:end]:
            if c == a or c == b:
                continue
            kumi.add(tuple(sorted([a,b,c])))
print(len(kumi))

Fixed submission:
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[j+1:], a+b)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations as com
N = int(input())
l = list(map(int, input().split()))
cnt = 0
for a, b, c in com(l, 3):
    if a < b+c and b < c+a and c < a+b:
        cnt+=1
print(cnt)

Fixed submission:
N = int(input())
l = sorted(list(map(int, input().split())))
 
from bisect import bisect_left

cnt = 0
for i in range(N):
    a = l[i]
    for j in range(i+1, N):
        b = l[j]
        cnt += bisect_left(l[j+1:], a+b)
print(cnt)