import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
import std.range;

auto readNum(T)(){
  return readln.chomp.to!T;
}

auto readNums(T)(){
  return readln.chomp.split.to!(T[]);
}

void main(){
  auto nm = readNums!int;
  auto a = readNums!long;

  a = sort(a).array;

  foreach(i; 0 .. nm[1]){
    auto bc = readNums!int;
    foreach(j; 0.. bc[0]){
      if(a[j] >= bc[1]) break;
      a[j] = bc[1];
    }
    a = sort(a).array;
  }

  writeln(a.sum);
}
