import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec
import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val as = mutable.PriorityQueue(in.readLine().split("\\s+").map(_.toInt): _*)(Ordering[Int].reverse)
    val bcs = mutable.PriorityQueue(Array.fill(m) {
      in.readLine().split("\\s+") match {
        case Array(b, c) => (b.toInt, c.toLong)
      }
    }: _*)(Ordering.by[(Int, Long), Long] {
      case (_, b) => b
    })

    @tailrec
    def max(sum: Long, i: Int): Long = {
      if (i == n) {
        sum
      } else if (bcs.isEmpty) {
        sum + as.foldLeft(0L)(_ + _)
      } else {
        val a = as.dequeue()
        val (b, c) = bcs.dequeue()
        if (a < c) {
          if (b > 1) {
            bcs.enqueue((b - 1, c))
          }
          max(sum + c, i + 1)
        } else {
          sum + a + as.foldLeft(0L)(_ + _)
        }
      }
    }

    out.println(max(0L, 0))

    out.flush()
  }
}
