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).toList
    val l = Array.tabulate(m) { _ =>
      val Array(b, c) = StdIn.readLine().split(" ").map(_.toLong)
      (b.toInt, c)
    }

    val ls = l.foldLeft(List.empty[Long]) {
      case (pre, (num, v)) => List.fill(num)(v) ::: pre
    }
    val r = (ls ::: As).sorted.takeRight(n)

    println(r.sum)
  }
}