n = gets.to_i
sticks = gets.split.map(&:to_i).sort

ans = 0

(0...(n - 2)).each{|left|
    ((left + 1)...(n - 1)).each{|right|
        first_ng = sticks.bsearch_index{|it| it >= sticks[left] + sticks[right]}
        first_ng = n if first_ng == nil 
        last_ok = first_ng - 1
        ans += last_ok - right
    }
}

puts ans