fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfLong()
    val BC = mutableListOf<Pair<Long, Long>>()
    for (n in 0 until N) BC.add(A[n] to 1)
    for (m in 0 until M) {
        val (b, c) = listOfLong()
        BC.add(c to b)
    }
    BC.sortByDescending { it.first }
    var ans = 0L
    var cnt = 0L + N
    for (n in 0 until BC.size) {
        if (cnt <= 0) break
        val C = Math.min(cnt, BC[n].second)
        ans += C * BC[n].first
        cnt -= C
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)