import Prelude ()
import Data.String
import GHC.Base
import GHC.Num
import GHC.Real
import System.IO
import Text.Read

import Data.List (sort)
--import Data.Vector.Mutable (MVector(..))
import Data.Vector.Unboxed

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

    print $ f v

f v = g v n 0 1 0
    where n = length v

g v n i j ans
    | i == n = ans
    | j == n = g v n (i+1) (i+2) ans
    | otherwise = g v n i (j+1) $ ans + length (h v (a+b) 0 n) - j - 1
        where a = unsafeIndex v i
              b = unsafeIndex v j

h v x start end
    | start == end = unsafeTake start v
    | otherwise = if unsafeIndex v mid < x then h v x (mid + 1) end else h v x start mid
        where mid = (start + end) `div` 2