Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
from collections import deque
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
first = deque(L)
count = 0
for i in range(N-2):
    l = first.popleft()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.popleft()
        n = len([i for i in second if i > l-m])
        if n > 0:
            count += n
        else:
            break
print(count)

Fixed submission:
from copy import copy
from collections import deque
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
first = deque(L)
count = 0
for i in range(N-2):
    l = first.pop()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.pop()
        n = len(second) - bisect.bisect_right(second,l-m)
        if n > 0:
            count += n
        else:
            break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
from collections import deque
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
first = deque(L)
count = 0
for i in range(N-2):
    l = first.popleft()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.popleft()
        third = copy(second)
        for k in range(N-i-j-1):
            n = third.popleft()
            if n > l - m:
                count += 1
            else:
                break
print(count)

Fixed submission:
from copy import copy
from collections import deque
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
first = deque(L)
count = 0
for i in range(N-2):
    l = first.pop()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.pop()
        n = len(second) - bisect.bisect_right(second,l-m)
        if n > 0:
            count += n
        else:
            break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
from collections import deque
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
first = deque(L)
count = 0
for i in range(N-2):
    l = first.popleft()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.popleft()
        third = copy(second)
        for k in range(N-i-j-1):
            n = third.popleft()
            if n > l - m:
                count += 1
            else:
                break
print(count)

Fixed submission:
from copy import copy
from collections import deque
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
first = deque(L)
count = 0
for i in range(N-2):
    l = first.pop()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.pop()
        n = len(second) - bisect.bisect_right(second,l-m)
        if n > 0:
            count += n
        else:
            break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
from collections import deque
import numpy as np
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
k = np.array(L)
first = deque(L)
count = 0
for i in range(N-2):
    l = first.popleft()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.popleft()
        n = np.count_nonzero(np.array(second) > (l-m))
        if n == 0:
            break
        else:
            count += n
print(count)

Fixed submission:
from copy import copy
from collections import deque
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
first = deque(L)
count = 0
for i in range(N-2):
    l = first.pop()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.pop()
        n = len(second) - bisect.bisect_right(second,l-m)
        if n > 0:
            count += n
        else:
            break
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import numpy as np
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
k = np.array(L)
count = 0
for i in range(N-2):
    l = k[i]
    for j in range(1,N-i-1):
        m = k[i+j]
        n = np.count_nonzero(k[i+j+1:] > (l-m))
        if n == 0:
            break
        else:
            count += n
print(count)

Fixed submission:
from copy import copy
from collections import deque
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
first = deque(L)
count = 0
for i in range(N-2):
    l = first.pop()
    second = copy(first)
    for j in range(1,N-i-1):
        m = second.pop()
        n = len(second) - bisect.bisect_right(second,l-m)
        if n > 0:
            count += n
        else:
            break
print(count)