N, M = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)
h  = Hash.new(0)
a.each do |num|
    h[num] += 1
end

M.times do |i|
    b, c = gets.split(" ").map(&:to_i)
    h[c] += b
end

h = h.sort.reverse.to_h
ans = 0
count = 0

loop do
    tmp = h.shift.to_a
    x = tmp[0]
    y = tmp[1]
    if (count + y) < N
        ans += x * y
        count += y
    else
        ans += x * (N - count)
        break
    end
end

puts ans