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

n = int(input())
length = list(map(lambda x:int(x), input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            c_candidates = length[j+1:]
            max_bar = bisect.bisect_left(c_candidates,a+b)
            ans += max_bar
            
print(ans)

Fixed submission:
import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)

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

n = int(input())
length = list(map(lambda x:int(x), input().split()))
length.sort()
ans = 0
for i in range(n):  
    a = length[i]
    for j in range(i+1,n):
        b = length[j]
        if i >= j:
            continue
        else:
            c_candidates = length[j+1:]
            min_bar = bisect.bisect_right(c_candidates,b-a)
            max_bar = bisect.bisect_left(c_candidates,a+b)
            ans += max_bar - min_bar
            
print(ans)

Fixed submission:
import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)

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

n = int(input())
length = list(map(lambda x:int(x), input().split()))
length.sort()
ans = 0
for i in range(n):
    a = length[i]
    for j in range(n):
        b = length[j]
        if i >= j:
            continue
        else:
            c_candidates = length[j+1:]
            min_bar = bisect.bisect_right(c_candidates,max(a-b, b-a))
            max_bar = bisect.bisect_left(c_candidates,a+b)
            ans += max_bar - min_bar
            
print(ans)

Fixed submission:
import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect
    
    n = int(input())
    length = list(map(lambda x:int(x), input().split()))
    length.sort()
    ans = 0
    for i in range(n):
        a = length[i]
        for j in range(n):
            b = length[j]
            if i >= j:
                continue
            else:
                c_candidates = length[j+1:]
                min_bar = bisect.bisect_right(c_candidates,max(a-b, b-a))
                max_bar = bisect.bisect_left(c_candidates,a+b)
                ans += max_bar - min_bar
                
    print(ans)

Fixed submission:
import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)

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

n = int(input())
length = list(map(lambda x:int(x), input().split()))
length.sort()
ans = 0
for i in range(n):
    a = length[i]
    for j in range(n):
        b = length[j]
        if i >= j:
            continue
        else:
            c_candidates = length[j+1:]
            min_bar = bisect.bisect_right(c_candidates,max(a-b, b-a))
            max_bar = bisect.bisect_left(c_candidates,a+b)
            ans += max_bar - min_bar
            
print(ans)

Fixed submission:
import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)