object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, M = sc.nextInt
    var A = List.fill(N)(sc.nextLong).sorted
    for (_ <- 0 until M) {
      val b = sc.nextInt
      val c = sc.nextLong
      if (A.head < c) {
        A = (A.take(b).map(x => {
          if (x < c) c
          else x
        }) ++ A.drop(b)).sorted
      }
    }

    println(A.sum)
  }
}