import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val Array(n, m) = StdIn.readLine().split(" ").map(_.toInt)
    val As = StdIn.readLine().split(" ").map(_.toLong).sorted
    val l = Array.tabulate(m) { _ =>
      val Array(b, c) = StdIn.readLine().split(" ").map(_.toLong)
      (b.toInt, c)
    }.sortBy(_._2)(Ordering.Long.reverse)

//    l.foreach(println(_))

    val result = new Array[Long](n)

    l.foldLeft(0) {
      case (pre, (num, v)) =>
        var index = pre
        var nIndex = 0
        while (index < n && nIndex < num) {
          result(index) = v
          nIndex += 1
          index += 1
        }
        index
    }
//    result.foreach(a => print(s"$a, "))
//    println()
    val r = (As ++ result).sorted(Ordering.Long.reverse).take(n)
//    r.foreach(a => print(s"$a, "))
//    println()

    println(r.sum)
  }
}