object Main {

  def main(args: Array[String]): Unit = {
    import scala.io.StdIn._
    
    val Array(n, m) = readLine().split(" ").map(_.toInt)
    val A: Array[Long] = readLine().split(" ").map(_.toLong).sorted
    val BC: Array[(Int, Long)] = (0 until m). map { _ =>
      val Array(_b, _c) = readLine().split(" ")
      (_b.toInt, _c.toLong)
    }. toArray. sortBy(_._2)(Ordering.Long.reverse)

    var ai = 0 // Aを見ている箇所
    var bci = 0 // BCを見ている箇所
    while (bci < m && ai < n && BC(bci)._2 > A(ai)) {
      val bc = BC(bci)._2 // 今回置き換える数
      var ic = 0
      while (ai < n && bc > A(ai) && ic < BC(bci)._1) {
        A(ai) = bc
        ic += 1
        ai += 1
      }
      bci += 1
    }
    println(A.sum)
  }

}