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

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

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

  in.readLine.split(" ").map(_.toLong).foreach { a =>
    map(a) = map.getOrElse(a, 0L) + 1
  }

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toLong))
    .foreach { e =>
      val v = e(0)
      val k = e(1)
      map(k) = map.getOrElse(k, 0L) + v
    }

  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)
}