from bisect import bisect_left
N=int(input())
triangle=[]
count=0
L=list(map(int,input().split()))
L.sort()
#print(L)
for a in range(N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1)
print(count) from bisect import bisect_left N=int(input()) N int(input()) int input() input triangle=[] triangle [] count=0 count 0 L=list(map(int,input().split())) L list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split L.sort() L.sort L sort for a in range(N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1) a range(N) range N for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1) b range(a+1,N) range a+1 a 1 N c=L[a]+L[b] c L[a]+L[b] L[a] L a L[b] L b zahyo=bisect_left(L,c) zahyo bisect_left(L,c) bisect_left L c count+=max(0,zahyo-b-1) count max(0,zahyo-b-1) max 0 zahyo-b-1 zahyo-b zahyo b 1 print(count) print count N=int(input()) int(input()) N zahyo=bisect_left(L,c) bisect_left(L,c) zahyo count+=max(0,zahyo-b-1) max(0,zahyo-b-1) count L=list(map(int,input().split())) list(map(int,input().split())) L triangle=[] [] triangle c=L[a]+L[b] L[a]+L[b] c count=0 0 count
from bisect import bisect_left
N=int(input())
triangle=[]
count=0
L=list(map(int,input().split()))
L.sort()
#print(L)
for a in range(N):
    for b in range(a+1,N):
        c=L[a]+L[b]
        zahyo=bisect_left(L,c)
        count+=max(0,zahyo-b-1)
print(count)
