def bisect_left(L,x):
  lo=0
  hi=N
  while lo<hi:
    mid=(lo+hi)//2
    if L[mid]<x: lo=mid+1
    else: hi=mid
  return lo

N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(N-2):
  a=L[i]
  for j in range(i+1,N-1):
    b=L[j]
    """
    lo=0
    hi=N
    x=a+b
    while lo<hi:
      mid=(lo+hi)//2
      if L[mid]<x: lo=mid+1
      else: hi=mid
    ans+=lo-(j+1) 
    """
    ans+=bisect_left(L,a+b)-(j+1)
print(ans) def bisect_left(L,x):
  lo=0
  hi=N
  while lo<hi:
    mid=(lo+hi)//2
    if L[mid]<x: lo=mid+1
    else: hi=mid
  return lo bisect_left lo=0 lo 0 hi=N hi N while lo<hi:
    mid=(lo+hi)//2
    if L[mid]<x: lo=mid+1
    else: hi=mid
   lo<hi lo hi mid=(lo+hi)//2 mid (lo+hi)//2 lo+hi lo hi 2 if L[mid]<x: lo=mid+1
    else: hi=mid
   L[mid]<x L[mid] L mid x return lo lo L L x x N=int(input()) N int(input()) int input() input 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=sorted(L) L sorted(L) sorted L ans=0 ans 0 for i in range(N-2):
  a=L[i]
  for j in range(i+1,N-1):
    b=L[j]
    """
    lo=0
    hi=N
    x=a+b
    while lo<hi:
      mid=(lo+hi)//2
      if L[mid]<x: lo=mid+1
      else: hi=mid
    ans+=lo-(j+1) 
    """
    ans+=bisect_left(L,a+b)-(j+1) i range(N-2) range N-2 N 2 a=L[i] a L[i] L i for j in range(i+1,N-1):
    b=L[j]
    """
    lo=0
    hi=N
    x=a+b
    while lo<hi:
      mid=(lo+hi)//2
      if L[mid]<x: lo=mid+1
      else: hi=mid
    ans+=lo-(j+1) 
    """
    ans+=bisect_left(L,a+b)-(j+1) j range(i+1,N-1) range i+1 i 1 N-1 N 1 b=L[j] b L[j] L j """
    lo=0
    hi=N
    x=a+b
    while lo<hi:
      mid=(lo+hi)//2
      if L[mid]<x: lo=mid+1
      else: hi=mid
    ans+=lo-(j+1) 
    """ ans+=bisect_left(L,a+b)-(j+1) ans bisect_left(L,a+b)-(j+1) bisect_left(L,a+b) bisect_left L a+b a b j+1 j 1 print(ans) print ans N=int(input()) int(input()) N L=sorted(L) sorted(L) L ans=0 0 ans b=L[j] L[j] b a=L[i] L[i] a ans+=bisect_left(L,a+b)-(j+1) bisect_left(L,a+b)-(j+1) ans L=list(map(int,input().split())) list(map(int,input().split())) L def bisect_left(L,x):
  lo=0
  hi=N
  while lo<hi:
    mid=(lo+hi)//2
    if L[mid]<x: lo=mid+1
    else: hi=mid
  return lo def bisect_left(L,x):
  lo=0
  hi=N
  while lo<hi:
    mid=(lo+hi)//2
    if L[mid]<x: lo=mid+1
    else: hi=mid
  return lo bisect_left
def bisect_left(L,x):
  lo=0
  hi=N
  while lo<hi:
    mid=(lo+hi)//2
    if L[mid]<x: lo=mid+1
    else: hi=mid
  return lo

N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(N-2):
  a=L[i]
  for j in range(i+1,N-1):
    b=L[j]
    """
    lo=0
    hi=N
    x=a+b
    while lo<hi:
      mid=(lo+hi)//2
      if L[mid]<x: lo=mid+1
      else: hi=mid
    ans+=lo-(j+1) 
    """
    ans+=bisect_left(L,a+b)-(j+1)
print(ans)
