import java.util.*
import java.util.Comparator



fun main(args: Array<String>){
    var (N,M) = readLine()!!.split(" ").map{ it.toLong()}
    var A = readLine()!!.split(" ").map{it.toLong()}

    var map = mutableMapOf<Long,Long>()

    for(i in 0 until N){
        if(map.containsKey(A[i.toInt()])){
            map.set(A[i.toInt()],map[A[i.toInt()]]!!+1)
        } else {
            map.set(A[i.toInt()],1)
        }
    }

    for(i in 0 until M){
        val (B,C) = readLine()!!.split(" ").map{it.toLong()}
        if(map.containsKey(C)){
            map.set(C,map[C]!!+B)
        } else{
            map.set(C,B)
        }
    }

    val comparator = Comparator<Long> { a, b ->
        when {
            a > b -> -1
            else -> 1
        }

    }

    val sortedMap = map.toSortedMap(comparator)
    
    var ans : Long =0

    var size = A.size.toLong()

    for((k,v) in sortedMap){

        if(size >= v){
            ans += k * v
            size -=v
        } else {
            ans  += k * size
            size =0
        }


        if(size == 0L) break
    }
    println(ans)



}