N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

h = Hash.new(0)

A.each do |a|
  h[a] += 1
end

M.times do
  b, c = gets.split.map(&:to_i)
  h[c] += b
end

remain = N
ans = 0
h.sort_by { |k, _| -k }.each do |key, _|
  count = [remain, h[key]].min
  remain -= count
  ans += key * count
  break if remain <= 0
end

puts ans
