import Data.List
{-
get_some :: Int -> [Int] -> [[Int]]

get_some 0 _ = [[]]
get_some 1 x = map (\a -> [a]) x
get_some n (x:xs) = (map (\a -> (x:a)) (get_some (n - 1) xs)) ++ (get_some n xs)
get_some _ [] = []

judge :: [Int] -> Bool
judge x = (a + b > c) && (b + c > a) && (c + a > b) where
    a = x !! 0
    b = x !! 1
    c = x !! 2

main = do
    getLine
    getLine >>= putStrLn . show . length . (filter judge) . (get_some 3) . (map read) . words
-}
{-
g :: Int -> [Int] -> Int
g a (b:bs) = (g a bs) + case (findIndex (>= (a + b)) bs) of
        Just n -> n
        Nothing -> length bs
g _ [] = 0

f :: [Int] -> Int
f (a:as) = (g a as) + (f as) where
f [] = 0

main = do
    getLine
    putStrLn . show . f . sort . (map read) . words =<< getLine

-}
{-
f :: Int -> Int -> [Int] -> Int
f _ _ [] = 0
f a b x = (n * (n + 1) `div` 2) + if n == length x then 0 else (f a (x !! m) (drop (m + 1) x)) where
    n = case (findIndex (>= (a + b)) x) of
        Just k -> k
        Nothing -> length x
    m = case (findIndex (> ((x!!n) - a)) x) of
        Just k -> k
        Nothing -> length x

g :: [Int] -> Int
g (x:(y:ys)) = (f x y ys) + (g (y:ys))
g xs = 0

main :: IO ()
main = do
    --getLine
    --putStrLn . show . g . sort . (map read) . words =<< getLine
    print $ f 2 4 [4,5,5]
-}
f :: Int -> [Int] -> Int -> Int -> Int
f a x m n 
    | n >= (length x) = 0
    | (a + (x !! m) > (x !! n)) = n - m + (f a x m (n + 1))
    | m + 1  == n = (f a x m (n + 1))
    | otherwise = f a x (m + 1) n

g :: [Int] -> Int
g [] = 0
g (a:x) = (f a x 0 1) + (g x)

main = do
    getLine
    x <- getLine >>= return . sort . (map (read :: String -> Int)) . words
    putStrLn $ show $ g x
    -- putStrLn $ show $ g [3,4,4,5,5]