import Data.List ( sort )

main :: IO ()
main = do
  n <- readLn :: IO Int
  ass <- map read . words <$> getLine :: IO [Int]
  print $ g ass

f :: [Int] -> [Int]
f [] = []
f (a:b:c:cs) = k : f cs
  where
    (_:k:_) = sort [a,b,c]
  
g = sum . f
