import Prelude             hiding (length)
import Control.Applicative ((<$>))
import Control.Monad       (replicateM)
import Data.List           (sort)
import Data.Vector.Unboxed (Vector(..), (!), fromList, length) 

main :: IO ()
main = do
  n <- readLn
  as <- replicateM n readLn
  print $ solve as

solve :: [Int] -> Int
solve = head . drop 2 . sort . comb . fromList . take 4 . sort

comb :: Vector Int -> [Int]
comb xs = [ (xs ! i) <++> (xs ! j) | i <- is, j <- is, i /= j ]
  where
    x <++> y = read (show x ++ show y)
    is = [0 .. (length xs - 1)]
