import Data.List
import Control.Monad

getInts :: IO [Int]
getInts = getLine >>= mapM readIO . words

solve :: [Int] -> [Int] -> [Int] -> Int
solve as bs cs = sum $ take n $ sortBy (flip compare) $ as ++ others
  where n = length as
        others = concat $ zipWith replicate bs cs

main :: IO ()
main = do
  [n, m] <- getInts
  as <- getInts
  [bs, cs] <- transpose <$> replicateM m getInts
  print $ solve as bs cs
