-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr, tails, sort)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS

isTriangle :: Int -> Int -> Int -> Bool
isTriangle a b c = a < b + c && b < c + a && c < a + b

naive = do
  n <- readLn :: IO Int
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ length [ (a,b,c) | a:xss <- tails xs, b:xsss <- tails xss, c <- xsss, isTriangle a b c ]

-- v は昇順にソートされているとする。
-- count a v は a 以上の要素の個数を数える。
countGE :: Int -> U.Vector Int -> Int
countGE a v | U.null v = 0
            | U.length v == 1 = case compare a (U.head v) of
                                  LT -> 1
                                  EQ -> 1
                                  GT -> 0
            | otherwise = let n = U.length v
                              n2 = n `quot` 2
                          in case compare a (v U.! n2) of
                               LT -> countGE a (U.take n2 v) + n - n2
                               EQ -> countGE a (U.take n2 v) + n - n2
                               GT -> countGE a (U.drop n2 v)

main = do
  n <- readLn :: IO Int
  xs <- U.fromListN n . sort . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ sum [ countGE (c_min + 1) ys - countGE c_max ys
              | i <- [0..n-1]
              , let a = xs U.! i
              , j <- [i+1..n-1]
              , let b = xs U.! j
              , let c_min = max (a - b) (b - a)
              , let c_max = a + b {- c < a + b, b - a < c, a - b < c -}
              , let ys = U.drop (j+1) xs
              ]
