n,m = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
b_c_list = []
for i in range(m):
  b_c_list.append(list(map(int,input().split())))

b_c_list.sort(key=lambda x: x[1],reverse = True)
                  
count = 0
d = []
for b_c in b_c_list:
  for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
    if count >= n:
      break
  if count >= n:
    break
    

for i in range(min(n,len(d))):
  if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
    
print(sum(a_list)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a_list = list(map(int,input().split())) a_list list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split a_list.sort() a_list.sort a_list sort b_c_list = [] b_c_list [] for i in range(m):
  b_c_list.append(list(map(int,input().split()))) i range(m) range m b_c_list.append(list(map(int,input().split()))) b_c_list.append b_c_list append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split b_c_list.sort(key=lambda x: x[1],reverse = True) b_c_list.sort b_c_list sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse = True reverse True count = 0 count 0 d = [] d [] for b_c in b_c_list:
  for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
    if count >= n:
      break
  if count >= n:
    break
     b_c b_c_list for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
    if count >= n:
      break
   i range(b_c[0]) range b_c[0] b_c 0 d.append(b_c[1]) d.append d append b_c[1] b_c 1 count += 1 count 1 if count >= n:
      break
   count >= n count n break if count >= n:
    break
     count >= n count n break for i in range(min(n,len(d))):
  if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
     i range(min(n,len(d))) range min(n,len(d)) min n len(d) len d if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
     a_list[i] < d[i] a_list[i] a_list i d[i] d i a_list[i] = d[i] a_list[i] a_list i d[i] d i break print(sum(a_list)) print sum(a_list) sum a_list count += 1 1 count a_list = list(map(int,input().split())) list(map(int,input().split())) a_list b_c_list = [] [] b_c_list m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n d = [] [] d count = 0 0 count
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
a_list.sort()
b_c_list = []
for i in range(m):
  b_c_list.append(list(map(int,input().split())))

b_c_list.sort(key=lambda x: x[1],reverse = True)
                  
count = 0
d = []
for b_c in b_c_list:
  for i in range(b_c[0]):
    d.append(b_c[1])
    count += 1
    if count >= n:
      break
  if count >= n:
    break
    

for i in range(min(n,len(d))):
  if a_list[i] < d[i]:
    a_list[i] = d[i]
  else:
    break
    
print(sum(a_list))