# after reading explanation
gets
l = gets.split.map(&:to_i)
l.sort!
n = l.length
ans = 0
[*2..n-1].reverse.each{|i|
  [*1..i-1].reverse.each{|j|
    s = j-1
    e = 0
    point = 0
    flag = true
    while flag
      point = (s+e)/2
      if l[i]<l[j]+l[point]
        flag = false if s==point
        s = point
      else
        flag = false if e==point
        e = point
      end
    end
    s = j if l[i]>=l[j]+l[j-1]
    ans += (j-s)
  }
}
p ans