Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input=sys.stdin.readline
n=int(input())
lists=list(map(int,input().split()))
listss=sorted(lists)
count=0
for i in range(n):
    for j in range(n):
        if i!=j:
            index1=bisect.bisect_left(listss, abs(listss[j]-listss[i])+1)
            index2=bisect.bisect_right(listss,listss[i]+listss[j]-1)
            count+=(index2-index1)
            x=abs(listss[j]-listss[i])
            if  x+1<=listss[i]:
                count-=1
            if x+1<=listss[j]:
                count-=1
print(count//6)


Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input=sys.stdin.readline
n=int(input())
lists=list(map(int,input().split()))
listss=sorted(lists)
count=0
for i in range(n):
    for j in range(n):
        if i!=j:
            index1=bisect.bisect_left(listss, abs(listss[j]-listss[i])+1)
            index2=bisect.bisect_right(listss,listss[i]+listss[j]-1)
            count+=(index2-index1)
            x=abs(listss[j]-listss[i])
            if  x+1<=listss[i]:
                count-=1
            if x+1<=listss[j]:
                count-=1
print(count//6)


Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
lists=list(map(int,input().split()))
listss=sorted(lists)
count=0
for i in range(n):
    for j in range(n):
        if i!=j:
            index1=bisect.bisect_left(listss, abs(listss[j]-listss[i])+1)
            index2=bisect.bisect_right(listss,listss[i]+listss[j]-1)
            count+=(index2-index1)
            x=abs(listss[j]-listss[i])
            if  x+1<=listss[i]:
                count-=1
            if x+1<=listss[j]:
                count-=1
print(count//6)

Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Buggy python submission (verdict: Runtime Error):
import cython
import bisect
n=int(input())
lists=list(map(int,input().split()))
listss=sorted(lists)
count=0
for i in range(n):
    for j in range(n):
        if i!=j:
            index1=bisect.bisect_left(listss, abs(listss[j]-listss[i])+1)
            index2=bisect.bisect_right(listss,listss[i]+listss[j]-1)
            count+=(index2-index1)
            x=abs(listss[j]-listss[i])
            if  x+1<=listss[i]:
                count-=1
            if x+1<=listss[j]:
                count-=1
print(count//6)

Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
lists=list(map(int,input().split()))
listss=sorted(lists)
count=0
for i in range(n):
    for j in range(n):
        if i!=j:
            index1= bisect.bisect_left(listss, abs(listss[j]-listss[i])+1)
            index2=bisect.bisect_right(listss,listss[i]+listss[j]-1)
            count+=(index2-index1)
            x=abs(listss[j]-listss[i])
            if  x+1<=listss[i]:
                count-=1
            if x+1<=listss[j]:
                count-=1
print(count//6)
            
    
        

Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
lists=list(map(int,input().split()))
listss=sorted(lists)

count=0

for i in range(n):
    for j in range(n):
        if i!=j:
            a=listss[i]+listss[j]
            # abs(lists[i]-lists[j]<a<b+cとなるものの個数を求める)
        
            index1= bisect.bisect_left(listss, abs(listss[j]-listss[i])+1)
            index2=bisect.bisect_right(listss,listss[i]+listss[j]-1)

            count+=(index2-index1)
            x=abs(listss[j]-listss[i])
            if  x+1<=listss[i]:
                count-=1
            if x+1<=listss[j]:
                count-=1


print(count//6)

Fixed submission:
import bisect
n=int(input())
lists=list(map(int,input().split()))
lists=sorted(lists)

cnt=0
import math
for i in range(n):
    for j in range(i+1,n):
        #i<j 
        x=lists[i]
        y=lists[j]
        left=i 
        right=j 
        index=bisect.bisect_right(lists,y-x)
        cnt+=min(j-i-1,j-index)

print(cnt)