n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1])
 
c_l=[]
for b,c in l:
  c_l+=[c]*b
  if len(c_l)>=n:
    break
 
for i in range(min(n,len(c_l))):
  a[i]=max(a[i],c_l[i])
 
print(sum(a)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=sorted(list(map(int,input().split()))) a sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split l=sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1]) l sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1]) sorted [list(map(int,input().split())) for i in range(m)] reverse=True reverse True key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x c_l=[] c_l [] for b,c in l:
  c_l+=[c]*b
  if len(c_l)>=n:
    break
  b c l c_l+=[c]*b c_l [c]*b [c] c b if len(c_l)>=n:
    break
  len(c_l)>=n len(c_l) len c_l n break for i in range(min(n,len(c_l))):
  a[i]=max(a[i],c_l[i])
  i range(min(n,len(c_l))) range min(n,len(c_l)) min n len(c_l) len c_l a[i]=max(a[i],c_l[i]) a[i] a i max(a[i],c_l[i]) max a[i] a i c_l[i] c_l i print(sum(a)) print sum(a) sum a a=sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) a c_l+=[c]*b [c]*b c_l l=sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1]) sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1]) l n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m c_l=[] [] c_l
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=sorted([list(map(int,input().split())) for i in range(m)],reverse=True,key=lambda x: x[1])
 
c_l=[]
for b,c in l:
  c_l+=[c]*b
  if len(c_l)>=n:
    break
 
for i in range(min(n,len(c_l))):
  a[i]=max(a[i],c_l[i])
 
print(sum(a))