import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 [n,m]<-map (read . BS.unpack) . BS.words <$> BS.getLine
 a<-map (read . BS.unpack) . BS.words <$> BS.getLine
 cb<-replicateM m ((\x->(x!!1,x!!0)).map (read . BS.unpack) . BS.words <$> BS.getLine)
 (print.sum)(take n (reverse(sort((f n m (reverse(sort cb)))++a))))
  where f n m cb = if n*m<=0 then [] else ((take(snd(head cb))(repeat(fst(head cb))))++(f (n-(snd(head cb))) (m-1) (tail cb)))