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)
  val mi = a.min
  val l  = a.length
  var retm :IndexedSeq[Long] = Vector.empty  

  (1 to m).foreach { i =>
    val Array(b, c)  = StdIn.readLine.split(" ").map(_.toInt)
    if (mi < c) {
      retm = IndexedSeq.fill(b)(c.toLong) ++ retm
    }
  }

  println((retm  ++ a).sorted.reverse.slice(0, l).sum)
}
  

