import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val ls = IntArray(n){scn.nextInt()}
	ls.sort()
	val arr = Array(n-1){b -> IntArray(b){a -> ls[b]+ls[a]} }
	var ans = 0
	for (c in 2 until n){
		for (b in 1 until c){
			var l = 0
			var r = b-1
			if (arr[b][r] <= ls[c]) continue
			if (ls[c] < arr[b][l]) {
				ans += b
				continue
			}
			while (r-l>1){
				val h = (l+r)/2
				if (ls[c] < arr[b][h]) r = h
				else l = h
			}
			ans += b-r
		}
	}
	println(ans)
}