n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
ope = readlines.map{|line| line.split.map(&:to_i)}
a.sort!
ope.sort!{|e,f| f[1] <=> e[1]}

sum = 0

ope.each do |i|
  if a[0] == nil
      break
  elsif a[0] >= i[1]
    sum += a.inject(:+)
    a = [0]
    break
  end
  i[0].times do
    if a[0] == nil
        break
    elsif a[0] < i[1]
      a.shift
      sum += i[1]
    else
      break
    end
  end
end

if a[0] == nil
    puts sum
else
    puts sum + a.inject(:+)
end