import java.util.*

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map{it.toInt()}
    val aa = readLine()!!.split(" ").map{it.toLong()}
    var total = aa.sum()

    val queue = PriorityQueue<Long>(n)
    queue.addAll(aa)

    val cards = mutableMapOf<Long, Long>()
    repeat(m) {
        val (b, c) = readLine()!!.split(" ").map{it.toLong()}
        cards[c] = (cards[c] ?: 0) + b
    }
    val keys = cards.keys.sortedDescending()

    for (key in keys) {
        for (i in 1..cards[key]!!) {
            if (queue.peek() < key) {
                val diff = key - queue.poll()
                total += diff
                queue.add(key)
            } else {
                break
            }
        }
    }

    println(total)
}