let ans, n = ref 0, Scanf.scanf " %d" (+) 0
let ls = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let g i k a = a.(i) <= k
let f k l a = let l, r = ref @@ l - 1, ref @@ Array.length a in while !r - !l > 1 do let m = !l + (!r - !l) / 2 in if g m k a then r := m else l := m done; !r
let _ = Array.(sort (fun x y -> y - x) ls; for i = 0 to n - 3 do for j = i + 1 to n - 2 do ans := !ans + f (ls.(i) - ls.(j)) (j + 1) ls - j - 1 done; done); Printf.printf "%d\n" !ans