N, M = map(int, input().split())
A = list(map(int, input().split()))

import numpy as np
import collections

count = 0
BC = []

# Python code to sort the tuples using second element  
# of sublist Inplace way to sort using sort() 
def Sort(sub_li): 
  
    # reverse = None (Sorts in Ascending order) 
    # key is set to sort using second element of  
    # sublist lambda has been used 
    sub_li.sort(key = lambda x: x[1]) 
    return sub_li 

for i in range (0, M):
	BC.append(list(map(int, input().split())))
    
BC = collections.deque(reversed(Sort(BC)))

Secondlist = []

V = 0

while count < N and BC:
	V = BC.popleft()
	for i in range (0, V[0]):
		Secondlist.append(V[1])
		count+=1

C = A+Secondlist
C = sorted(C, reverse = True)
print(sum(C[:N])) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split import numpy as np numpy import collections collections count = 0 count 0 BC = [] BC [] def Sort(sub_li): 
  
    # reverse = None (Sorts in Ascending order) 
    # key is set to sort using second element of  
    # sublist lambda has been used 
    sub_li.sort(key = lambda x: x[1]) 
    return sub_li  Sort sub_li.sort(key = lambda x: x[1]) sub_li.sort sub_li sort key = lambda x: x[1] key lambda x: x[1] x[1] x 1 x return sub_li sub_li sub_li sub_li for i in range (0, M):
	BC.append(list(map(int, input().split())))
     i range (0, M) range 0 M BC.append(list(map(int, input().split()))) BC.append BC append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split BC = collections.deque(reversed(Sort(BC))) BC collections.deque(reversed(Sort(BC))) collections.deque collections deque reversed(Sort(BC)) reversed Sort(BC) Sort BC Secondlist = [] Secondlist [] V = 0 V 0 while count < N and BC:
	V = BC.popleft()
	for i in range (0, V[0]):
		Secondlist.append(V[1])
		count+=1 count < N and BC count < N count N BC V = BC.popleft() V BC.popleft() BC.popleft BC popleft for i in range (0, V[0]):
		Secondlist.append(V[1])
		count+=1 i range (0, V[0]) range 0 V[0] V 0 Secondlist.append(V[1]) Secondlist.append Secondlist append V[1] V 1 count+=1 count 1 C = A+Secondlist C A+Secondlist A Secondlist C = sorted(C, reverse = True) C sorted(C, reverse = True) sorted C reverse = True reverse True print(sum(C[:N])) print sum(C[:N]) sum C[:N] C :N N BC = [] [] BC C = sorted(C, reverse = True) sorted(C, reverse = True) C A = list(map(int, input().split())) list(map(int, input().split())) A BC = collections.deque(reversed(Sort(BC))) collections.deque(reversed(Sort(BC))) BC Secondlist = [] [] Secondlist M = map(int, input().split()) map(int, input().split()) M V = 0 0 V count = 0 0 count V = BC.popleft() BC.popleft() V count+=1 1 count N, M = map(int, input().split()) map(int, input().split()) N def Sort(sub_li): 
  
    # reverse = None (Sorts in Ascending order) 
    # key is set to sort using second element of  
    # sublist lambda has been used 
    sub_li.sort(key = lambda x: x[1]) 
    return sub_li  def Sort(sub_li): 
  
    # reverse = None (Sorts in Ascending order) 
    # key is set to sort using second element of  
    # sublist lambda has been used 
    sub_li.sort(key = lambda x: x[1]) 
    return sub_li  Sort C = A+Secondlist A+Secondlist C
N, M = map(int, input().split())
A = list(map(int, input().split()))

import numpy as np
import collections

count = 0
BC = []

# Python code to sort the tuples using second element  
# of sublist Inplace way to sort using sort() 
def Sort(sub_li): 
  
    # reverse = None (Sorts in Ascending order) 
    # key is set to sort using second element of  
    # sublist lambda has been used 
    sub_li.sort(key = lambda x: x[1]) 
    return sub_li 

for i in range (0, M):
	BC.append(list(map(int, input().split())))
    
BC = collections.deque(reversed(Sort(BC)))

Secondlist = []

V = 0

while count < N and BC:
	V = BC.popleft()
	for i in range (0, V[0]):
		Secondlist.append(V[1])
		count+=1

C = A+Secondlist
C = sorted(C, reverse = True)
print(sum(C[:N]))