from bisect import bisect_left
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+=bisect_left(y,tmp)-j-1
print(ans) from bisect import bisect_left 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+=bisect_left(y,tmp)-j-1 i range(N-2) range N-2 N 2 for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bisect_left(y,tmp)-j-1 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+=bisect_left(y,tmp)-j-1 ans bisect_left(y,tmp)-j-1 bisect_left(y,tmp)-j bisect_left(y,tmp) bisect_left y tmp j 1 print(ans) print ans N=int(input()) int(input()) N y=list(map(int, input().split())) list(map(int, input().split())) y ans=0 0 ans ans+=bisect_left(y,tmp)-j-1 bisect_left(y,tmp)-j-1 ans tmp=y[i]+y[j] y[i]+y[j] tmp
from bisect import bisect_left
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+=bisect_left(y,tmp)-j-1
print(ans)
