N,M=gets.split.map(&:to_i)
A=gets.split.map(&:to_i).sort
BC=M.times.map{gets.split.map(&:to_i)}.sort_by{|a|-a[1]}

ans = 0
BC.each do |b,c|
    #t = A.bsearch_index{|x| x>c} || N
    #t = b if t > b
    t = A[0, b].index {|x| x >= c } || [b, N].min

    break if t == 0
    ans += c*t
    A.shift(t)
end

puts ans + (A.inject(:+) || 0)
