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

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

Fixed submission:
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from copy import copy
import bisect
 
n = int(input())
order = sorted(list(map(int, input().split())))
l = deque(order)
ans = 0
 
for _ in range(len(l)-2):
    first = l.pop()
    m = copy(l)
    for _ in range(len(m)-1):
        second = m.pop()
        fix = first-second
        ans += len(m)-bisect.bisect_right(list(m), fix)
 
print(ans)

Fixed submission:
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from copy import copy
import bisect

n = int(input())
order = sorted(list(map(int, input().split())))
l = deque(order)
ans = 0

for _ in range(len(l)-2):
    first = l.pop()
    m = copy(l)
    for _ in range(len(m)-1):
        second = m.pop()
        fix = first-second
        ans += len(m)-bisect.bisect_right(list(m), fix)

print(ans)

Fixed submission:
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from copy import copy

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

for _ in range(len(l)-2):
    first = l.pop()
    m = copy(l)
    for _ in range(len(m)-1):
        second = m.pop()
        n = copy(m)
        for _ in range(len(n)):
            third = n.pop()
            if (first < second + third) & (second < first + third) & (third < first + second):
                ans += 1

print(ans)


Fixed submission:
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
l = deque(sorted(list(map(int, input().split()))))
ans = 0

for _ in range(len(l)-2):
    first = l.pop()
    m = l.copy()
    for _ in range(len(m)-1):
        second = m.pop()
        n = m.copy()
        fix = first - second
        if fix == 0:
            break
        else:
            for _ in range(len(n)):
                third = n.pop()
                if fix < third:
                    ans += 1
                else:
                    break

print(ans)

Fixed submission:
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque

_ = int(input())
l = deque(sorted(list(map(int, input().split()))))
ans = 0

for _ in range(len(l)-2):
    first = l.pop()
    m = l.copy()
    for _ in range(len(m)-1):
        second = m.pop()
        n = m.copy()
        fix = first - second
        if fix == 0:
            break
        else:
            for _ in range(len(n)):
                third = n.pop()
                if fix < third:
                    ans += 1
                else:
                    break

print(ans)

Fixed submission:
from bisect import bisect_right

n = int(input())
order = sorted(list(map(int, input().split())))
ans = 0

for i in reversed(range(2, n)):
    for j in reversed(range(1, i)):
        ans += j - bisect_right(order[0:j], order[i]-order[j])

print(ans)