def proc_num(a,b,c)
  i=0
  while(a[i]<c && i<b)
    a[i]=c
    i=i+1
  end
  return a.sort!
end


n,m = gets.chop.split.map(&:to_i)
a=Array.new(n)
b=Array.new(m)
c=Array.new(m)

a=gets.chop.split.map(&:to_i)

for i in 0...m
  b[i], c[i]=gets.chop.split.map(&:to_i)
end

a.sort!

for i in 0...m
  a=proc_num(a,b[i],c[i])
end

result=a.inject(:+)

puts result
