import Data.List
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as B8

getInts :: IO [Int]
getInts = do
  s <- B8.getLine
  return $! map (fst . fromJust . B8.readInt) $ B8.words s

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
