str1 = gets.split
N,M = str1[0].to_i, str1[1].to_i

str1 = gets.chomp.split
a = []
i = 0
while i < N 
  a[i] = str1[i].to_i
  i += 1
end
a.sort!
a.reverse!

b = []
i = 0
while i < N 
  b.push(a[i],1)
  i += 1
end

i = 0
l = 0
r = N-1
p = (l+r)/2
x = 0
y = 0
while i < M
  str1 = gets.split
  y,x = str1[0].to_i, str1[1].to_i
  if x > b[N*2-2]
    l = 0
    r = N-1
    p = (l+r)/2
    while l != r
      if x == b[p*2]
        l = p
        r = p
      elsif x > b[p*2]
        r = p
      else
        l = p+1
      end
      p = (l+r)/2
    end
    b.insert(l*2,x,y)
  end
  i += 1
end

i = 0
j = 1
answer = 0
while i < N
  if N >= i+b[j]
    answer += b[j-1] * b[j]
    i += b[j]
  else
    answer += b[j-1] * (N-i)
    i = N
  end
  j += 2
end
puts answer