import java.util.*

fun main(arr:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val numList = mutableListOf<Card>()
    numList.addAll(readLine()!!.split(" ").map { Card(it.toLong(), 1) })
    numList.addAll((1..m).map { readLine()!!.split(" ").map { it.toLong() }.let { Card(it[1], it[0].toInt()) } })

    var remain = n
    var ans = 0L
    for(c in numList.sortedByDescending { it.number }) {
        if(remain >= c.cont) {
            ans += (c.number * c.cont)
            remain -= c.cont
        } else {
            ans += (c.number * remain)
            remain = 0
            break
        }
    }
    println(ans)
}

class Card(val number:Long, val cont:Int):Comparable<Card> {
    override fun compareTo(other: Card): Int {
        return other.number.compareTo(this.number)
    }
}