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

object Main extends App {
  import MapHelper._

  val in = new BufferedReader(new InputStreamReader(System.in))
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val map = mu.HashMap.empty[Long,Int]

  in.readLine.split(" ").map(_.toLong).foreach(map.addOrUpdate(_,1))
  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach(e => map.addOrUpdate(e(1), e(0)))

  val keys = map.keys.toArray.sorted(Ordering[Long].reverse)
  def rec(acc:Long, cnt:Int, i:Int):Long = {
    val v = keys(i)
    val p =  map(keys(i))
    if(cnt + p >= n) acc + v * (n - cnt)
    else rec(acc + v * p, cnt + p, i + 1)
  }

  val ans = rec(0, 0, 0)
  println(ans)

  object MapHelper {
    implicit class AddOrUpdate[A](map:mu.HashMap[Long,Int]) {
      def addOrUpdate(key:Long, value:Int):mu.HashMap[Long,Int] =
      {
        if(map.contains(key)) map(key) += value
        else map += (key -> value)
        map
      }
    }
  }
}