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

# comb = list(combinations(l, 3))

ans = 0
l.sort(reverse=True)
# for i in comb:
#     a = i[0]
#     b = i[1]
#     c = i[2]
#     if (a < b + c) and (b < c + a) and (c < a + b):
#         ans += 1

for i in range(n):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        for k in range(j + 1, n):
            c = l[k]
            # print(a, b, c)
            if (a < b + c) and (b < c + a) and (c < a + b):
                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):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)

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

for i in range(n):
    for j in range(i, n - i):
        a = l[i]
        b = l[j]
        for k in range(j, n - i - j):
            c = l[k]
            if (a < b + c) and (b < c + a) and (c < a + b):
                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):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)

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

for i in range(n):
    for j in range(i, n - i):
        a = l[i]
        b = l[j]
        for k in range(j, n - i - j):
            c = l[k]
            if (a < b + c) and (b < c + a) and (c < a + b):
                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):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

comb = list(combinations(l, 3))

ans = 0
for i in comb:
    a = i[0]
    b = i[1]
    c = i[2]
    if (a < b + c) and (b < c + a) and (c < a + b):
        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):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

comb = list(combinations(l, 3))

ans = 0
for i in comb:
    a = i[0]
    b = i[1]
    c = i[2]
    if (a < b + c) and (b < c + a) and (c < a + b):
        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):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

comb = list(combinations(l, 3))

ans = 0
for i in range(len(comb)):
    a = comb[i][0]
    b = comb[i][1]
    c = comb[i][2]
    if (a < b + c) and (b < c + a) and (c < a + b):
        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):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        idx = bisect_left(l, a + b)
        # print(a, b, idx)

        ans += idx - (j + 1)


print(ans)