fun main(args: Array<String>) {
  val (N, M) = readInts()
  val A = readInts().sorted()
  val BC = (1..M).map { readInts() }.sortedByDescending { it[1] }
  val A2 = mutableListOf<Int>()
  BC.forEach {
    val (B, C) = it
    repeat(B) {
      A2.add(C)
      if (A2.size >= N) return@forEach
    }
  }

  var sum = 0L
  for (i in 0 until N) {
    sum += Math.max(A[i], A2.getOrNull(i) ?: 0)
  }
  println(sum)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(' ')
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
