input_nk = gets.chomp
n,m = input_nk.split.collect{ |item| item.to_i}
alist = gets.chomp.split.collect{ |item| item.to_i}
result = Hash.new(0)#Array.new(n+1).map{ 0}
alist.each do |i|
  result[i] += 1
end
blist = []
clist = []
m.times do |i|
  b,c = gets.chomp.split.collect{ |item| item.to_i}
  result[c] += b
end

sum = 0
count = 0
data = result.sort{ |(k1,v1),(k2,v2)| k2 <=> k1}
data.each do |one|
  sum += one[0] * one[1]
  count += one[1]
  if count >= n
    sum -= one[0]* (count-n)
    break
  end
end
puts sum