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

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

  if (retm.length >= l) {
    println(retm.slice(0, l).sum)
  } else  {
      println((retm ++ reto ++ a).sorted.reverse.slice(0, l).sum)
  }
}
  

