Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

L.sort()
#print(L)
if N == 3:
    if L[0] + L[1] > L[2]:
        print("1")
        sys.exit()

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        for k in range(j+1,len(L)):
            if L[i] + L[j] > L[k]:
                ans += 1
                #print(L[i], L[j], L[k])
            else:
                #print("break")
                break
print(ans)


Fixed submission:
import sys
import bisect
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

L.sort()
#print(L)
if N == 3:
    if L[0] + L[1] > L[2]:
        print("1")
        sys.exit()

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        index = bisect.bisect_left(L,L[i]+L[j],j+1)
        #print(index)
        ans += (index - 1) - (j + 1) + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

L.sort()
#print(L)
if N == 3:
    if L[0] + L[1] > L[2]:
        print("1")
        sys.exit()

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        for k in range(j+1,len(L)):
            if L[i] + L[j] > L[k]:
                ans += 1
                #print(L[i], L[j], L[k])
            else:
                #print("break")
                break
print(ans)

Fixed submission:
import sys
import bisect
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

L.sort()
#print(L)
if N == 3:
    if L[0] + L[1] > L[2]:
        print("1")
        sys.exit()

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        index = bisect.bisect_left(L,L[i]+L[j],j+1)
        #print(index)
        ans += (index - 1) - (j + 1) + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

# print(list(combinations(L,3)))

for i, j ,k in list(combinations(L, 3)):
    if i < j + k and j < i + k and k < i + j:
        ans += 1
print(ans)


Fixed submission:
import sys
import bisect
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

L.sort()
#print(L)
if N == 3:
    if L[0] + L[1] > L[2]:
        print("1")
        sys.exit()

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        index = bisect.bisect_left(L,L[i]+L[j],j+1)
        #print(index)
        ans += (index - 1) - (j + 1) + 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

# print(list(combinations(L,3)))

for i, j ,k in list(combinations(L, 3)):
    if i < j + k and j < i + k and k < i + j:
        ans += 1
print(ans)


Fixed submission:
import sys
import bisect
N = int(input())
L = [i for i in map(int, input().split())]
ans = 0

L.sort()
#print(L)
if N == 3:
    if L[0] + L[1] > L[2]:
        print("1")
        sys.exit()

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        index = bisect.bisect_left(L,L[i]+L[j],j+1)
        #print(index)
        ans += (index - 1) - (j + 1) + 1
print(ans)