#!/usr/bin/ruby
# encoding: utf-8

#main

# input 
N,M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = Array.new(M)
C = Array.new(M)

(0..M-1).each do |i|
  B[i],C[i] = gets.split.map(&:to_i)
end

sumB = 0
(0..M-1).each do |i|
  sumB += B[i]
end

fulAry = Array.new(N+sumB)

# +で配列の結合ができる。
# BiはCi個

fulAry = A

# この二重loopでTLE
(0..M-1).each do |i|
  B[i].times do |j|
    fulAry.push(C[i])
  end
end

fulAry.sort!.reverse!
#p fulAry

sum = 0

(0..N-1).each do |i|
  sum += fulAry[i]
end 

puts sum
