import java.util.*
class Rewrite(b: Int, c: Int) {
    val b = b
    val c = c
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val m = cin.nextInt()
    val a: MutableList<Int> = mutableListOf()
    for (i in 0..n-1) {
        a.add(cin.nextInt())
    }
    var rw: MutableList<Rewrite> = mutableListOf()
    for (i in 0..m-1) {
        rw.add(Rewrite(cin.nextInt(), cin.nextInt()))
    }
    val a_s: MutableList<Int> = a.sorted().toMutableList()
    val rws = rw.sortedByDescending {it.c}

    var i = 0
    var now = 0
    var nowused = 0
    while (n > i && m > now) {
        if (rws[now].c > a_s[i]) {
            a_s[i] = rws[now].c
        } else {
            break
        }
        i += 1
        nowused += 1
        if (nowused >= rws[now].b) {
            now += 1
            nowused = 0
        }
    }
    var ans: Long = 0
    for (j in 0..n-1) {
        ans += a_s[j].toLong()
    }
    println(ans)
}