import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

data class Item(val value: Long, val count: Long): Comparable<Item> {
    override operator fun compareTo(other: Item): Int =
        when {
            this.value != other.value -> other.value.compareTo(this.value)
            this.count != other.count -> this.count.compareTo(other.count)
            else -> 0
        }
}

fun func() {
    val (N, M) = listOfInt()
    val a = listOfLong()
    val ABC: MutableList<Item> = arrayListOf()
    for (n in 0 until N) ABC.add(Item(a[n], 1))
    for (m in 0 until M) {
        val (b, c) = listOfLong()
        ABC.add(Item(c, b))
    }
    ABC.sort()
    var ans = 0L
    var cnt = N.toLong()
    var n = 0
    while (cnt > 0) {
        val C = Math.min(cnt, ABC[n].count)
        ans += C * ABC[n].value
        cnt -= C.toLong()
        n++
    }
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) } //{ it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }
