n,m = gets.split.map(&:to_i)
ar = gets.split.map(&:to_i).sort
sets = []
m.times do
  sets << gets.split.map(&:to_i)
end

sets.sort_by!{|a,b| -b}

sets.each do |a,b|
  a.times do |i|
    if ar[i] < b
      ar[i] = b
    else
      break
    end
  end
  ar.sort!
end

puts ar.inject(&:+)