N,M=gets.split.map(&:to_i)
AS=gets.split.map(&:to_i)
BCS=M.times.map { gets.split.map(&:to_i) }

as = AS.sort
bcs = BCS.sort {|a,b| a[1] <=> b[1]}.reverse

now = 0
bcs.each do |bs|
  bs[0].times do
    if bs[1] > as[now] 
      as[now] = bs[1]
      now+=1
    elsif now >= N
      break
    else
      break
    end
  end
end

p as.inject(:+)
