import Control.Monad
import Data.List
main=do
 [n,m]<-map read.words<$>getLine
 a<-map read.words<$>getLine
 cb<-replicateM m ((\x->(x!!1,x!!0)).map read.words<$>getLine)
 print(f n m (reverse(sort cb)) (reverse(sort a)) 0)
  where f 0 _ _ _ i = i
        f n 0 _ a i = i+(sum(take n a))
        f n m ((c,0):cb) a i = f n (m-1) cb a i
        f n m ((c,b):cb) (j:a) i = if c>j then(f(n-1)m((c,b-1):cb)(j:a)(i+c))else(f(n-1)m((c,b):cb)a(i+j))