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

object Main extends App {
  import MapHelper._
  val map = mu.HashMap.empty[Long, Long]

  val Array(n, m) = in.readLine.split(" ").map(_.toInt)

  in.readLine.split(" ").map(_.toLong).foreach {
    map.addOrUpdate(_, 1)
  }

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

  val entries = map.iterator.toArray.sortBy(_._1)(Ordering[Long].reverse)

  def rec(acc: Long, cnt: Long, i:Int): Long = {
    val k = entries(i)._1
    val v = entries(i)._2
    if(cnt + v >= n) acc + k * (n - cnt)
    else rec(acc + (k * v), cnt + v, i + 1)
  }

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

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