lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]
C = 10 ** 10

a = []
for i in 1..N do
  a[i-1] = lines[1][i-1]
end

b = []
for i in 1..M do
  b[i-1] = lines[i+1][1] * C + lines[i+1][0]
end
b.sort!

i = 0
a2 = []
while i <= N and b != [] do
  num = b[-1] / C
  fois = b[-1] % C
  if fois > 0 then
    a2.push(num)
    b[-1] -= 1
    i += 1
  else
    b.pop
  end
end
  
for i in 1..a2.length do
  a.push(a2[i-1])
end
a.sort!
  
ans = 0
for i in 1..N do
  ans += a[-i]
end

puts ans