n,m=gets.split.map(&:to_i)
as=gets.split.map(&:to_i).sort{|a,b| b<=>a}
bcs=m.times.map{gets.split.map(&:to_i)}.sort{|a,b| b[1]<=>a[1]}
new=[]
while new.size<n
  if bcs.size==0||as[0]>bcs[0][1]
    v=as.shift
    new.push(v)
  elsif as.size==0||as[0]<=bcs[0][1]
    v=bcs.shift
    new.push([v[1]]*[v[0],n-new.size].min)
    new.flatten!
  end
end
puts new.inject(:+)
