import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined

--readInt = fst . fromJust . BS.readInteger
--readIntTuple = tuplify2 . map readInt . BS.words
--readIntList = map readInt . BS.words
--
--getInt = readInt <$> BS.getLine
--getIntList = readIntList <$> BS.getLine
--getIntMatrix = map readIntList . BS.lines <$> BS.getContents
--getIntTuple = readIntTuple <$> BS.getLine
--getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

readInt = read :: String -> Integer
readIntTuple = tuplify2 . map readInt . words
readIntList = map readInt . words

getInt = readInt <$> getLine
getIntList = readIntList <$> getLine
getIntMatrix = map readIntList . lines <$> getContents
getIntTuple = readIntTuple <$> getLine
getIntTuples = map readIntTuple . lines <$> getContents

main = do
  [n,m] <- getIntList
  as <- getIntList
  bcs <- getIntTuples
  let as' = sortBy (comparing Down) as
  let bcs' = sortBy (comparing Down `on` snd) bcs
  print $ f as' bcs' n

f _ _ 0 = 0
f as [] n = sum $ take (fromIntegral n) as
f as@(a:xs) bcs@((b,c):ys) n
  | n < 0 = undefined
  | a > c =
--      trace ("a = "++show(a)++show(as))
      a + f xs bcs (n-1)
  | b > n = n*c
  | otherwise =
--      trace ("(b,c) = "++show(b,c)++show(bcs))
      b*c + f as ys (n-b)