main = do
  getLine
  as<-map read.words<$>getLine :: IO [Int]
  print $ solve as

solve [a,b] = a+b
solve as = minimum $ map solve vals where
  vals = go [head as] (tail as)
  go (x:xs) (c:y:ys) = ( reverse xs ++ [x+c,y+c] ++ ys ) : go (c:x:xs) (y:ys)
  go _ _ = []