local mab, mce, mfl, msq, mmi, mma = math.abs, math.ceil, math.floor, math.sqrt, math.min, math.max

local function lower_bound(ary, x, right)
  if(x <= ary[1]) then return 1 end
  local num = right
  if(ary[num] < x) then return num + 1 end
  local min, max = 1, num
  while(1 < max - min) do
    local mid = mfl((min + max) / 2)
    if(ary[mid] < x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local ior = io.input()
local n, m = ior:read("*n", "*n")
local bc = {}
for i = 1, n do
  local a = ior:read("*n")
  local tmp = {1, a}
  table.insert(bc, tmp)
end
for i = 1, m do
  local b, c = ior:read("*n", "*n")
  local tmp = {b, c}
  table.insert(bc, tmp)
end
table.sort(bc, function(x, y) return x[2] > y[2] end)

local sum = 0
local rem = n
for i = 1, n + m do
  local num, val = bc[i][1], bc[i][2]
  num = mmi(rem, num)
  sum = sum + val * num
  rem = rem - num
  if rem == 0 then break end
end
print(99999999999999 < sum and "100000000000000" or sum)
