Buggy python submission (verdict: Time Limit Exceeded):
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data.sort()
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            # c += bisect_left(data, data[i] + data[j], j) - j - 1
            c += bisect_left(data[j+1:], data[i] + data[j])


    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)



Fixed submission:
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data.sort()
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            c += bisect_left(data, data[i] + data[j], j) - j - 1

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data = sorted(data)
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            c += bisect_left(data[j+1:], data[i] + data[j])

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)



Fixed submission:
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data.sort()
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            c += bisect_left(data, data[i] + data[j], j) - j - 1

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data = sorted(data)
    c = 0
    for i in range(N):
        for j in range(i+1, N-1):
            max_t = data[i] + data[j]
            max_i = bisect_right(data[j+1:], max_t-1)

            c += max_i

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)



Fixed submission:
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data.sort()
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            c += bisect_left(data, data[i] + data[j], j) - j - 1

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
# a < b + c
# b < a + C
# c < a + b

# 3 4 2 1
# a b c 

# abs(a - b) < c

def solution(N, data): # O(N^2 * logN)
    data = sorted(data)
    c = 0
    for i in range(N):
        for j in range(i+1, N-1):
            min_t = abs(data[i] - data[j])
            min_i = bisect_left(data[j+1:], min_t+1)
            max_t = data[i] + data[j]
            max_i = bisect_right(data[j+1:], max_t-1)
            # print(f'i: {i}, j: {j}, min_i: {min_i}, max_i: {max_i}')

            c += max_i - min_i

    return c

from math import ceil, floor
from bisect import bisect_left, bisect_right

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)

    # a = bisect_right([4], 5)
    # b = bisect_left([4], 5)

    # print(a)
    # print(b)

    # a = binary_search_min_index([3, 4, 7, 8], 2)
    # print(a)





Fixed submission:
# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data.sort()
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            c += bisect_left(data, data[i] + data[j], j) - j - 1

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)