#!/usr/bin/env ruby

map = {}
n, m = gets.split(' ').map &:to_i
cards = gets.split(' ').map &:to_i
cards.each do |num|
  map[num] ||= 0
  map[num] += 1
end

m.times do
  b, c = gets.split(' ').map &:to_i
  map[c] ||= 0
  map[c] += b
end


sum = 0
card_num = 0
map.keys.sort.reverse.each do |key|
  sum += key * map[key]
  card_num += map[key]
  if card_num >= n
    sum -= key * (card_num - n)
    break
  end
end

puts sum
