object Main extends App {

  val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  var a: Array[Int] = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  (1 to m).foreach { _ =>
    val Array(b, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val cc: Array[Int] = Array.fill(b)(c)
    a ++= cc
  }

  println(a.sorted.takeRight(n).map(_.toLong).sum)
}