import java.util.Scanner

import scala.annotation.tailrec
import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val aa = StdIn.readLine().split(" ").map(_.toInt)
    val N = aa.head
    val M = aa.tail.head
    val As = StdIn.readLine().split(" ").map(_.toLong).toList
    val l = (1 to M).map(_ => StdIn.readLine().split(" ").map(_.toLong).toList).map(a => (a.head.toInt, a.tail.head))

    val ls = l.foldLeft(List.empty[Long]) {
      case (pre, (num, v)) => List.fill(num)(v) ::: pre
    }
    val r = (ls ::: As).sorted.takeRight(N)

    println(r.sum)
  }
}