input = gets.chomp.split
n = input[0].to_i
m = input[1].to_i

a = gets.chomp.split(" ").map(&:to_i)
bc = []

for i in 1..m do
    bc.push(gets.chomp.split(" ").map(&:to_i))
end

a.sort!
bc.sort! {| x,y | y[1] <=> x[1]}

i = 0
j = 0
while i < m
    b = bc[i][0]
    c = bc[i][1]
    for k in 1..b 
        if a[j] < c
            a[j] = c
            j += 1
            if j >= m 
                i = m
                break
            end
        else
            i = m
            break
        end
    end
    i += 1
end

sum = 0
for i in 1..n do
    sum += a[i-1]
end
p sum
