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

array = []

m.times do
  b, c = gets.split(' ').map(&:to_i)
  b.times{array << c}
end

array.sort! {|a, b| b <=> a }

for i in 0..(array.length-1) do
  if array[0] > a[i]
    a[i] = array[0]
    array.shift
  else
    break
  end
end

sum = 0
a.each { |i| sum += i }

puts sum
