N = gets.to_i
ls = gets.split(' ').map(&:to_i).sort
count = 0
(0..(N - 3)).each do |a|
  if a > 501
    count += (N - a) * (N - a - 1) * (N - a - 2) / 6
    break
  end
  ((a + 1)..(N - 2)).each do |b|
    if ls[a] + ls[b] > 1000
      count += (N - b) * (N - b - 1) / 2 
      break
    end
    i = ls.bsearch_index { |c| c >= ls[a] + ls[b] } || N
    count += i - (b + 1)
  end
end
p count