import bisect
n=int(input())
lis=list(map(int, input().split())) 
lis.sort()
out=0
for i in range(n):
    for j in range(1+i,n):
        out+=bisect.bisect_left(lis,lis[i]+lis[j])-j-1
print(out) import bisect bisect n=int(input()) n int(input()) int input() input lis=list(map(int, input().split())) lis list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split lis.sort() lis.sort lis sort out=0 out 0 for i in range(n):
    for j in range(1+i,n):
        out+=bisect.bisect_left(lis,lis[i]+lis[j])-j-1 i range(n) range n for j in range(1+i,n):
        out+=bisect.bisect_left(lis,lis[i]+lis[j])-j-1 j range(1+i,n) range 1+i 1 i n out+=bisect.bisect_left(lis,lis[i]+lis[j])-j-1 out bisect.bisect_left(lis,lis[i]+lis[j])-j-1 bisect.bisect_left(lis,lis[i]+lis[j])-j bisect.bisect_left(lis,lis[i]+lis[j]) bisect.bisect_left bisect bisect_left lis lis[i]+lis[j] lis[i] lis i lis[j] lis j j 1 print(out) print out out+=bisect.bisect_left(lis,lis[i]+lis[j])-j-1 bisect.bisect_left(lis,lis[i]+lis[j])-j-1 out n=int(input()) int(input()) n lis=list(map(int, input().split())) list(map(int, input().split())) lis out=0 0 out
import bisect
n=int(input())
lis=list(map(int, input().split())) 
lis.sort()
out=0
for i in range(n):
    for j in range(1+i,n):
        out+=bisect.bisect_left(lis,lis[i]+lis[j])-j-1
print(out)