import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  for j in range(i+1,n):
    index=bisect.bisect_left(l,l[i]+l[j])
    ans+=index-j-1
print(ans) import bisect bisect n=int(input()) n int(input()) int input() input l=sorted(list(map(int,input().split()))) l sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ans=0 ans 0 for i in range(n):
  for j in range(i+1,n):
    index=bisect.bisect_left(l,l[i]+l[j])
    ans+=index-j-1 i range(n) range n for j in range(i+1,n):
    index=bisect.bisect_left(l,l[i]+l[j])
    ans+=index-j-1 j range(i+1,n) range i+1 i 1 n index=bisect.bisect_left(l,l[i]+l[j]) index bisect.bisect_left(l,l[i]+l[j]) bisect.bisect_left bisect bisect_left l l[i]+l[j] l[i] l i l[j] l j ans+=index-j-1 ans index-j-1 index-j index j 1 print(ans) print ans ans=0 0 ans index=bisect.bisect_left(l,l[i]+l[j]) bisect.bisect_left(l,l[i]+l[j]) index l=sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) l ans+=index-j-1 index-j-1 ans n=int(input()) int(input()) n
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
  for j in range(i+1,n):
    index=bisect.bisect_left(l,l[i]+l[j])
    ans+=index-j-1
print(ans)