import itertools
import bisect

N = int(input())
LS = list(map(int,input().split()))
LS.sort()

ans = 0

for a,b in itertools.combinations(LS,2):
  a,b = min(a,b),max(a,b)
  lo = b - a
  up = a + b
  
  cnt = bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1
  if lo < a:
    cnt -= 1
    
  if cnt <= 0:
    continue
    
  ans += cnt
  
print(ans // 3)
 import itertools itertools import bisect bisect N = int(input()) N int(input()) int input() input LS = list(map(int,input().split())) LS list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split LS.sort() LS.sort LS sort ans = 0 ans 0 for a,b in itertools.combinations(LS,2):
  a,b = min(a,b),max(a,b)
  lo = b - a
  up = a + b
  
  cnt = bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1
  if lo < a:
    cnt -= 1
    
  if cnt <= 0:
    continue
    
  ans += cnt
   a b itertools.combinations(LS,2) itertools.combinations itertools combinations LS 2 a,b = min(a,b),max(a,b) a min(a,b) min a b b max(a,b) max a b lo = b - a lo b - a b a up = a + b up a + b a b cnt = bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1 cnt bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1 bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) bisect.bisect_left(LS,up) bisect.bisect_left bisect bisect_left LS up bisect.bisect_right(LS,lo) bisect.bisect_right bisect bisect_right LS lo 1 if lo < a:
    cnt -= 1
    
   lo < a lo a cnt -= 1 cnt 1 if cnt <= 0:
    continue
    
   cnt <= 0 cnt 0 continue ans += cnt ans cnt print(ans // 3) print ans // 3 ans 3 ans = 0 0 ans lo = b - a b - a lo cnt = bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1 bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1 cnt cnt -= 1 1 cnt b = min(a,b),max(a,b) max(a,b) b N = int(input()) int(input()) N ans += cnt cnt ans a,b = min(a,b),max(a,b) min(a,b) a LS = list(map(int,input().split())) list(map(int,input().split())) LS up = a + b a + b up
import itertools
import bisect

N = int(input())
LS = list(map(int,input().split()))
LS.sort()

ans = 0

for a,b in itertools.combinations(LS,2):
  a,b = min(a,b),max(a,b)
  lo = b - a
  up = a + b
  
  cnt = bisect.bisect_left(LS,up) - bisect.bisect_right(LS,lo) - 1
  if lo < a:
    cnt -= 1
    
  if cnt <= 0:
    continue
    
  ans += cnt
  
print(ans // 3)

