import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    var a = readLine()!!.split(" ").map{it.toLong()}.toMutableList()
    a.sort()
    val b = ArrayList<Pair<Long,Long>>()
    repeat(m){
        val (c, d) = readLine()!!.split(" ").map{it.toLong()}
        b.add(Pair(c, d))
    }
    b.sortBy{it.second}
    b.reverse()
    var j = 0
    for(i in 0 until m){
        for(k in 0 until b[i].first) {
            if (j == n || b[i].second <= a[j]) break
            a[j] = b[i].second
            j++
        }
        if(j == n) break
    }
    println(a.sum())
}
