object Main {

  import java.util.Scanner
  import scala.util.control.Breaks

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    var a = (1 to n).map(_ => sc.nextLong()).sorted.toArray
    debug(n, m, a.toSeq)

    val br = new Breaks
    (1 to m).map(_ => (sc.nextInt(), sc.nextLong())).foreach { case (b, c) =>
      var replaced = false
      br.breakable {
        for (i <- 0 until b) {
          if (a(i) < c) {
            a(i) = c
            replaced = true
          } else br.break()
        }
      }
      if (replaced) a = a.sorted
    }
    a.sum.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}
