n, m = gets.chomp.split(" ").map(&:to_i)
a_arr = gets.chomp.split(" ").map(&:to_i).sort
min = a_arr.min

arr = []
m.times do |i|
  arr << gets.chomp.split(" ").map(&:to_i)
end
arr.sort_by!{|(b,c)| -c }

index = 0
arr.each do |(b, c)|
  next if c <= min
  b.times do |i|
    a_arr[index + i] = c if a_arr[index + i] < c
  end
  index += b
  break if index >= n
end

puts a_arr.inject(0) {|sum,x| sum + x }

