import collections
N,M = map(int, input().split())
A = list(map(int,input().split()))
D = collections.Counter(A)

A.sort()
max = 0 

for i in range(M):
    B,C = map(int, input().split())
    D[C] += B  

D = sorted(D.items(), key=lambda x:x[0],reverse=True)

sum = 0 
count = 0 
for k,v in D:
    if N > v : 
        sum += k * v
        N -= v 
    else : 
        sum += k * N 
        break 
print(sum) import collections collections 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 D = collections.Counter(A) D collections.Counter(A) collections.Counter collections Counter A A.sort() A.sort A sort max = 0 max 0 for i in range(M):
    B,C = map(int, input().split())
    D[C] += B   i range(M) range M B,C = map(int, input().split()) B map(int, input().split()) map int input().split() ().split () input split C D[C] += B D[C] D C B D = sorted(D.items(), key=lambda x:x[0],reverse=True) D sorted(D.items(), key=lambda x:x[0],reverse=True) sorted D.items() D.items D items key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x reverse=True reverse True sum = 0 sum 0 count = 0 count 0 for k,v in D:
    if N > v : 
        sum += k * v
        N -= v 
    else : 
        sum += k * N 
        break  k v D if N > v : 
        sum += k * v
        N -= v 
    else : 
        sum += k * N 
        break  N > v N v sum += k * v sum k * v k v N -= v N v sum += k * N sum k * N k N break print(sum) print sum N,M = map(int, input().split()) map(int, input().split()) N count = 0 0 count sum += k * N k * N sum N -= v v N sum = 0 0 sum M = map(int, input().split()) map(int, input().split()) M D = collections.Counter(A) collections.Counter(A) D C = map(int, input().split()) map(int, input().split()) C sum += k * v k * v sum A = list(map(int,input().split())) list(map(int,input().split())) A B,C = map(int, input().split()) map(int, input().split()) B D = sorted(D.items(), key=lambda x:x[0],reverse=True) sorted(D.items(), key=lambda x:x[0],reverse=True) D max = 0 0 max
import collections
N,M = map(int, input().split())
A = list(map(int,input().split()))
D = collections.Counter(A)

A.sort()
max = 0 

for i in range(M):
    B,C = map(int, input().split())
    D[C] += B  

D = sorted(D.items(), key=lambda x:x[0],reverse=True)

sum = 0 
count = 0 
for k,v in D:
    if N > v : 
        sum += k * v
        N -= v 
    else : 
        sum += k * N 
        break 
print(sum)