import java.util.*
import java.math.*

fun main(args: Array<String>) {

    var (N, M) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toLong()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }
    val A = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    val mod = 1000000007L

    A.sort()
    A.reverse()
    val BC = mutableMapOf<Long,Long>()
    for (i in 0 until M) {
        var (B, C) = readLine()!!.split(" ").map { it.toLong() }
        BC[C] = B + (BC[C]?:0)
    }

    val list = BC.toList().sortedBy { -it.first }

    var ans = mutableListOf<Long>()

    var a = 0
    var l = 0
    var sc = 0L

    while (ans.size < N) {
        var ad = 0L
        if (l >= list.size || A[a] >= list[l].first) {
            ad = A[a]
            a++
        }else {
            ad = list[l].first
            sc++
            if (list[l].second == sc) {
                l++
                sc = 0
            }
        }
        ans.add(ad)
    }

    print(ans.sum())
}