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

object Main extends App {
  import MapHelper._

  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val a = in.readLine.split(" ").map(_.toLong)
  val map = mu.HashMap.empty[Long,Int]

  a.foreach { i =>
    map.addOrUpdate(i, 1)
  }

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach { e =>
      map.addOrUpdate(e(1),e(0))
    }
  
  var i = 0
  var cnt = 0
  var acc = 0L
  val keys = map.keys.toArray.sorted(Ordering[Long].reverse)
  val end = keys.size
  while(cnt <= n) {
    cnt += map(keys(i))
    // println(keys(i) + " " + map(keys(i)))
    if(cnt <= n) acc += keys(i) * map(keys(i))
    else if(cnt > n) acc += keys(i) *(map(keys(i)) - (cnt - n))
    i += 1
  }
  val ans = acc
  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
      }
    }
  }
}