import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val seq = in.readLine.split(" ").map(_.toInt)

  val map = mu.HashMap.empty[Int, Int]
  seq.foreach(i => map.put(i, map.getOrElse(i, 0) + 1))
  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach(e => map.put(e(1), map.getOrElse(e(1), 0) + e(0)))

  val keys = map.keys.toArray.sorted(Ordering[Int].reverse).iterator

  def rec(acc:Long, cnt:Int):Long = {
    val key = keys.next()
    val value = map(key)
    if(cnt - value < 1) acc + key.toLong * cnt
    else rec(acc + key.toLong * value, cnt - value)
  }

  val ans = rec(0L, n)
  println(ans)
}