n,m = gets.split.map {|x| x.to_i}
a = gets.split.map {|x| x.to_i}

a.sort!

bc = []
m.times { |i|
  bc << gets.split.map {|x| x.to_i}
}
bc.sort!{|a,b| a[0]<=>b[0]}
#p bc

s = 0
rem = n
i = a.size-1
j = bc.size-1
while rem > 0
  if j < 0 or a[i] > bc[j][1]
    #puts a[i]
    s += a[i]
    i -= 1
    rem -= 1
  else
    if rem > bc[j][0]
      k = bc[j][0]
    else
      k = rem
    end
    #puts bc[j][1]
    s += bc[j][1]*k
    rem-=k
    j-=1
  end
end

puts s
