fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val a = readIntList().sorted()
    val b = List(m) { readIntList() }.sortedBy { it[1] }.reversed()

    var i = 0
    var ans = 0L
    b.forEach { (num, to) ->
        for (j in 0 until num) {
            if (i >= n) break
            if (i < n) {
                if (a[i] < to) {
                    ans += to
                } else {
                    ans += a[i]
                }
                i++
            }
        }
    }

    for (j in i until n) {
        ans += a[j]
    }

    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)