object Main {

  import scala.collection.mutable.ListBuffer

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, M = sc.nextInt
    val A = List.fill(N)(sc.nextLong).sorted
    val D = ListBuffer.empty[Long]
    for (_ <- 0 until M) {
      val b = sc.nextInt
      val c = sc.nextLong
      D ++= ListBuffer.fill(b)(c)
    }
    D ++= A
    val result = D.sorted.reverse.take(N).sum

    println(result)
  }
}