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 = a

  (1 to m).foreach { i =>
    val Array(b, c)  = StdIn.readLine.split(" ").map(_.toInt)
    val d = ret.filter(_ < c).length
    ret = Array.fill(b.min(d))(c.toLong) ++ ret.sorted.drop(b.min(d))

  }

  println(ret.sum)
}
  

