import Data.List

main :: IO ()
main = do
    l1 <- getLine
    l2 <- getLine
    let l = map read $ words l2 :: [Int]

    print $ f l

f l = sum $ zipWith g (tails $ tail l') l'
    where l' = sort l

g [] _ = 0
g l x = sum $ zipWith (\l' -> h l' x) (tails $ tail l) l

h l x y = length $ takeWhile (< x+y) l