module S = Set.Make(struct
  type t = int * int * int
  let compare (x, _, i) (y, _, j) = if x <> y then x - y else i - j
end)

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun i -> Scanf.scanf " %d" @@ fun x -> x, 1, i+1) in
  let bc = Array.init m (fun i -> Scanf.scanf " %d %d" @@ fun b c -> (c, b, -i)) in
  let pq =
    let f s (x, c, i) = S.add (x, c, i) s in
    Array.fold_left f (Array.fold_left f S.empty a) bc
  in
  let rec aux tot sc pq =
    let (x, c, _) as p = S.max_elt pq in
    let pq' = S.remove p pq in
    if sc+c >= n then tot + x*(n-sc)
    else aux (tot + x*c) (sc+c) pq'
  in
  aux 0 0 pq |> Printf.printf "%d\n"
