
n, m = gets.chomp.split(" ").map {|item| item.to_i }
cardAList = gets.chomp.split(" ").map {|item| item.to_i }.sort!
bcList = []
m.times do |j|
    bcList[j] = gets.chomp.split(" ").map {|item| item.to_i }
end
bcList.sort!{|a, b| a[1] <=> b[1]}

bcList.each do |bc|
    bc[0].times do |i|
        if cardAList[i] < bc[1]
            cardAList[i] = bc[1]
        else
            break
        end
    end
end

puts cardAList.inject(:+)