n,m=map(int,input().split())
A=list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
bc = sorted(bc,key=lambda x:-x[1])

sub = []
for i in range(m):
   sub += [bc[i][1]] * bc[i][0]
   if len(sub) > n:
       break

A += sub

print(sum(sorted(A,reverse=True)[: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 list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split bc = [list(map(int,input().split())) for _ in range(m)] bc [list(map(int,input().split())) for _ in range(m)] bc = sorted(bc,key=lambda x:-x[1]) bc sorted(bc,key=lambda x:-x[1]) sorted bc key=lambda x:-x[1] key lambda x:-x[1] -x[1] x[1] x 1 x sub = [] sub [] for i in range(m):
   sub += [bc[i][1]] * bc[i][0]
   if len(sub) > n:
       break i range(m) range m sub += [bc[i][1]] * bc[i][0] sub [bc[i][1]] * bc[i][0] [bc[i][1]] bc[i][1] [i] bc i 1 bc[i][0] [i] bc i 0 if len(sub) > n:
       break len(sub) > n len(sub) len sub n break A += sub A sub print(sum(sorted(A,reverse=True)[:n])) print sum(sorted(A,reverse=True)[:n]) sum sorted(A,reverse=True)[:n] (A,reverse=True) sorted A reverse=True reverse True :n n bc = sorted(bc,key=lambda x:-x[1]) sorted(bc,key=lambda x:-x[1]) bc m=map(int,input().split()) map(int,input().split()) m sub = [] [] sub sub += [bc[i][1]] * bc[i][0] [bc[i][1]] * bc[i][0] sub n,m=map(int,input().split()) map(int,input().split()) n A=list(map(int,input().split())) list(map(int,input().split())) A bc = [list(map(int,input().split())) for _ in range(m)] [list(map(int,input().split())) for _ in range(m)] bc A += sub sub A
n,m=map(int,input().split())
A=list(map(int,input().split()))
bc = [list(map(int,input().split())) for _ in range(m)]
bc = sorted(bc,key=lambda x:-x[1])

sub = []
for i in range(m):
   sub += [bc[i][1]] * bc[i][0]
   if len(sub) > n:
       break

A += sub

print(sum(sorted(A,reverse=True)[:n]))