fun main(args: Array<String>) {
    abc127d()
}

private data class Operation(val amount: Int, val value: Long)

fun abc127d() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val numbers = readLine()!!.split(" ").map { it.toLong() }
        .sorted().toMutableList()
    val operations = (1..m).map { readLine()!!.split(" ").map { it.toLong() } }
        .map { Operation(it[0].toInt(), it[1]) }.sortedByDescending { it.value }

    val changeValues = mutableListOf<Long>()
    op@ for (operation in operations) {
        val changeValue = (1..operation.amount).map { operation.value }
        for (cv in changeValue) {
            if (changeValues.size >= n) break@op
            changeValues.add(cv)
        }
    }

    // 二分探索したほうがよさそうではある
    var changes = changeValues.size
    for (i in changeValues.indices) {
        if (changeValues[i] <= numbers[i]) {
            changes = i
            break
        }
    }

    val answer = (changeValues.take(changes) + numbers.drop(changes)).sum()

    println(answer)
}
