n, m = gets.chomp.split.map(&:to_i)
h = Hash.new(0)

gets.chomp.split.each do |a|
  h[a.to_i] += 1
end

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

sum = 0
h.sort_by{|num, count| -num}.each do |num, count|
  if count < n
    sum += count * num
    n -= count
  else
    sum += n * num
    break
  end
end

puts(sum)