fun main(args: Array<String>) {
    val (n, m) = readInputLine().split(" ").map { it.toLong() }
    
    val aList = readInputLine().split(" ").map { it.toLong() }.toMutableList()
    aList.sort()
    
    // c -> b
    val changeMap = mutableMapOf<Long, Long>()
    
    for (i in 1..m) {
        val (b, c) = readInputLine().split(" ").map { it.toLong() }
        
        val oldB = changeMap.get(c) ?: 0L
        
        changeMap.put(c, oldB + b)
    }
    
    var index = 0
    
    // 小さい方から貪欲に大きい数に変えていく
    for ((k, v) in changeMap.toList().sortedByDescending { it.first }) {
        for (i in 0 until v) {
            if (aList[index] < k) {
                aList[index] = k
                index = (index + 1) % aList.size
            } else {
                break
            }
        }
    }
    
    println(aList.sum())
}

fun readInputLine(): String {
    return readLine()!!
}
