fun main(args:Array<String>) {
    val (N,M) = readLine()!!.split(" ").map(String::toInt)
    val a_integers = readLine()!!.split(" ").map(String::toLong)
 
    val b_c = (1..M).map {
        val (b,c) = readLine()!!.split(" ").map(String::toLong)
        Pair(b.toInt(),c)
    }.sortedByDescending {it.second} 

    val result_list = mutableListOf<Long>()

    outer@ for ((b,c) in b_c) {
        for (i in (1..b)) {
            result_list.add(c)
            if(result_list.size >= N) {
                break@outer
            }
        }
    }
    result_list.addAll(a_integers)
    result_list.sortedDescending().take(N).fold(0L) {sum,ele-> sum+ele}.run(::println)
}