Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]

import random
import time
from bisect import bisect_left

L_len = len(L)
L.sort()

count = 0
for i in range(0, L_len - 2):
    for j in range(i + 1, L_len - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length, lo = j + 1, hi = L_len)
        count += idx - j - 1

print(count)


Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]

import random
from bisect import bisect_left

L_len = len(L)
L.sort()

count = 0
for i in range(0, L_len - 2):
    for j in range(i + 1, L_len - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length, lo = j + 1, hi = L_len)
        count += idx - j - 1

print(count)


Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]

L_len = len(L)

L.sort(reverse=True)

count = 0
for i in range(0, L_len - 2):
    for j in range(i + 1, L_len - 1):
        left = j + 1
        right = L_len - 1
        length = L[i] - L[j]
        index = -1
        while right >= left  :
            center = int((left + right + 1)/2)
            if L[center] > length:
                index = 0
                left = center
                if left == right:
                    break

            else:
                right = center - 1
            

        if index != -1:
            count += right - j

print(count)

Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]

L_len = len(L)

L.sort(reverse=True)

count = 0
for i in range(L_len - 2):
    for j in range(i + 1, L_len - 1):
        for k in range(j + 1, L_len):
            if L[i] < L[j] + L[k]:
                count += 1
            else:
                break

print(count)

Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]

L_len = len(L)

count = 0
for i in range(L_len - 2):
    for j in range(i + 1, L_len - 1):
        for k in range(j + 1, L_len):
            f = 0
            if L[i] >= L[j] + L[k]:
                f = 1
            if L[j] >= L[i] + L[k]:
                f = 1
            if L[k] >= L[i] + L[j]:
                f = 1
            
            if f == 0:
                count += 1

print(count)

Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [int(i) for i in input().split()]

L_len = len(L)

count = 0
for i in range(L_len - 2):
    for j in range(i + 1, L_len - 1):
        for k in range(j + 1, L_len):
            f = 0
            if a >= b + c:
                f = 1
            if b >= a + c:
                f = 1
            if c >= a + b:
                f = 1
            
            if f == 0:
                count += 1

print(count)

Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]

from bisect import bisect_left

L.sort()

count = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        length = L[i] + L[j]
        idx = bisect_left(L, length)
        count += idx - j - 1

print(count)