n, m = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)

cnt = Hash.new{|h,k| h[k] = 0}
n.times do |i|
  cnt[a[i]] += 1
end

m.times do |i|
  b, c = gets.split(" ").map(&:to_i)
  cnt[c] += b
end


cnt = cnt.sort_by{|k,v| -k}
ans = 0


cnt.length.times do |i|
  if n <= cnt[i][1]
    ans += cnt[i][0] * n
    break
  else
    ans += cnt[i][0] * (cnt[i][1])
    n -= cnt[i][1]
  end
end

puts ans
