n,m = $stdin.gets.split.map(&:to_i)
a = $stdin.gets.split.map(&:to_i)
a.sort!
ary = []
m.times do |i|
  ary[i]=$stdin.gets.split.map(&:to_i)
end
ary.sort!{|a,b| a[1] <=> b[1]}.reverse!

result = 0
j=0
n.times do |i|
  if !ary[j].nil?&&a[i]<ary[j][1]
    a[i]=ary[j][1]
    ary[j][0]-=1
    if ary[j][0]==0
      j += 1
    end
  end

  result += a[i]
end

puts result