import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App{


  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val cards = readLine.trim.split(' ').map(_.toLong).sorted
  val op = Array.tabulate(m){_ ⇒
    val Array(b, c) = readLine.trim.split(' ').map(_.toInt)
    (b, c.toLong)
  }.sortBy(_._2)(Ordering.Long.reverse)
  var left = 0

  var sum = 0L

  for ((b, c) ← op) {
    val right = lowerBound(cards, left, c)
    if (right - left > b) {
      left += b
      sum += b * c
    }else {
      sum += (right - left) * c
      left = right
    }
  }
  println(sum + (left until cards.size).map{i ⇒ cards(i)}.sum)








  def lowerBound(array: Array[Long], from: Int, target: Long): Int = {
    var left = from
    var right = array.size
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) < target) {
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
}