import scala.io.StdIn


object Main extends App {
  val Array(n, m)  = StdIn.readLine.split(" ").map(_.toInt)
  val a :Array[Long] = StdIn.readLine.split(" ").map(_.toLong)
  var ret :Vector[Long] = Vector.empty

  (1 to m).foreach { i =>
    val Array(b, c)  = StdIn.readLine.split(" ").map(_.toInt)
    ret = Vector.fill(b)(c.toLong) ++ ret
  }


  println((a ++ ret).sorted.reverse.slice(0, a.length).sum)
}
  

