{-# LANGUAGE TypeApplications #-}

-- | D - Chat in a Circle
module Main where

import Data.List (sort)

main :: IO ()
main = do
  _ <- readLn @Int
  as <- map (read @Int) . words <$> getLine
  print $ (sum . tail . sort) as
