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

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = bisect_right(L[j+1:], abs(l1-l2))
            e = bisect_left(L[j+1:], l1+l2)

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = max(j+1, bisect_right(L, abs(l1-l2)))
            e = max(j+1, bisect_left(L, l1+l2))

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

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

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = bisect_right(L[j+1:], abs(l1-l2))
            e = bisect_left(L[j+1:], l1+l2)

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = max(j+1, bisect_right(L, abs(l1-l2)))
            e = max(j+1, bisect_left(L, l1+l2))

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

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

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = bisect_right(L[j+1:], abs(l1-l2))
            e = bisect_left(L[j+1:], l1+l2)

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = max(j+1, bisect_right(L, abs(l1-l2)))
            e = max(j+1, bisect_left(L, l1+l2))

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

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

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = bisect_right(L[j+1:], abs(l1-l2))
            e = bisect_left(L[j+1:], l1+l2)

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)

Fixed submission:
from bisect import bisect_left, bisect_right

N = int(input())
L = list(map(int, input().split()))

L.sort()

count = 0
for i, l1 in enumerate(L):
    for j, l2 in enumerate(L):
        if i < j:
            s = max(j+1, bisect_right(L, abs(l1-l2)))
            e = max(j+1, bisect_left(L, l1+l2))

            # print((i, j), (l1, l2), (abs(l1-l2), l1+l2), (s, e))
            count += max(0, e-s)
            # abs(l1-l2) <= m <= l1+l2

print(count)