require 'set'

n, m = gets.chomp!.split(" ").map!(&:to_i)
a_n = gets.chomp!.split(" ").map!(&:to_i).sort_by!{|x| x }

x = SortedSet.new(a_n)
bc_m = {}

a_n.each do |a|
    bc_m[a] = (bc_m[a] || 0) + 1 
    x << a
end

m.times do |i|
    b, c = gets.chomp!.split(" ").map!(&:to_i)
    bc_m[c] = (bc_m[c] || 0) + b
    x << c
end

sum = 0
count = 0
x.reverse_each do |i|
    if count + bc_m[i] >= n
        sum += ((n - count) * i)
        break
    else
        sum += bc_m[i] * i
        count += bc_m[i]
    end
end

puts sum
