
object Main extends App {
  val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var a = scala.io.StdIn.readLine.split(" ").map(_.toLong).sorted
  (1 to m).foreach { _ =>
    val Array(b, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    (1 to b).foreach { _ =>
      if (a.head < c) {
        a = (c.toLong +: a.tail).sorted
      }
     // println(a.deep)
    }
  }


  println(a.sum)
}