import scala.collection.mutable

object Main {

  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 groupedA = A.groupBy(identity).mapValues(_.size).toMap
    val map: mutable.HashMap[Long, Int] = mutable.HashMap.from(groupedA)
    for (_ <- 0 until M) {
      val b = sc.nextInt
      val c = sc.nextLong
      if (map.contains(c)) {
        map(c) = map(c) + b
      } else {
        map(c) = b
      }
    }
    val sorted = map.toSeq.sortBy(_._1).reverse
    var count = N
    var result = 0L
    for (cards <- sorted) {
      if (count <= cards._2) {
        result += count * cards._1
        println(result)
        sys.exit
      } else {
        result += cards._2 * cards._1
        count -= cards._2
      }
    }

  }
}