import bisect as bs
N=int(input())
y=list(map(int, input().split()))
y.sort()
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bs.bisect_left(y[(j+1):],tmp)
    
print(ans)
 import bisect as bs bisect N=int(input()) N int(input()) int input() input y=list(map(int, input().split())) y list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split y.sort() y.sort y sort ans=0 ans 0 for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bs.bisect_left(y[(j+1):],tmp)
     i range(N-2) range N-2 N 2 for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bs.bisect_left(y[(j+1):],tmp)
     j range(i+1, N-1) range i+1 i 1 N-1 N 1 tmp=y[i]+y[j] tmp y[i]+y[j] y[i] y i y[j] y j ans+=bs.bisect_left(y[(j+1):],tmp) ans bs.bisect_left(y[(j+1):],tmp) bs.bisect_left bs bisect_left y[(j+1):] y (j+1): j+1 j 1 tmp print(ans) print ans tmp=y[i]+y[j] y[i]+y[j] tmp y=list(map(int, input().split())) list(map(int, input().split())) y N=int(input()) int(input()) N ans=0 0 ans ans+=bs.bisect_left(y[(j+1):],tmp) bs.bisect_left(y[(j+1):],tmp) ans
import bisect as bs
N=int(input())
y=list(map(int, input().split()))
y.sort()
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bs.bisect_left(y[(j+1):],tmp)
    
print(ans)

