N,M= map(int,input().split())
l=list(map(int,input().split()))
tmp=[]
for i in l:
   tmp.append((1,i))
for i in range(M):
   A,B=list(map(int,input().split()))
   tmp.append((A,B))
from operator import itemgetter
tmp.sort(reverse=True,key=itemgetter(1))
ans,cnt=0,N
for v,s in tmp:
   nd=min(v,cnt)
   ans+=nd*s
   cnt-=nd
print(ans) N,M= map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M l=list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split tmp=[] tmp [] for i in l:
   tmp.append((1,i)) i l tmp.append((1,i)) tmp.append tmp append (1,i) 1 i for i in range(M):
   A,B=list(map(int,input().split()))
   tmp.append((A,B)) i range(M) range M A,B=list(map(int,input().split())) A list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split B tmp.append((A,B)) tmp.append tmp append (A,B) A B from operator import itemgetter tmp.sort(reverse=True,key=itemgetter(1)) tmp.sort tmp sort reverse=True reverse True key=itemgetter(1) key itemgetter(1) itemgetter 1 ans,cnt=0,N ans 0 cnt N for v,s in tmp:
   nd=min(v,cnt)
   ans+=nd*s
   cnt-=nd v s tmp nd=min(v,cnt) nd min(v,cnt) min v cnt ans+=nd*s ans nd*s nd s cnt-=nd cnt nd print(ans) print ans N,M= map(int,input().split()) map(int,input().split()) N tmp=[] [] tmp A,B=list(map(int,input().split())) list(map(int,input().split())) A ans,cnt=0,N 0 ans cnt=0,N N cnt cnt-=nd nd cnt l=list(map(int,input().split())) list(map(int,input().split())) l M= map(int,input().split()) map(int,input().split()) M B=list(map(int,input().split())) list(map(int,input().split())) B nd=min(v,cnt) min(v,cnt) nd ans+=nd*s nd*s ans
N,M= map(int,input().split())
l=list(map(int,input().split()))
tmp=[]
for i in l:
   tmp.append((1,i))
for i in range(M):
   A,B=list(map(int,input().split()))
   tmp.append((A,B))
from operator import itemgetter
tmp.sort(reverse=True,key=itemgetter(1))
ans,cnt=0,N
for v,s in tmp:
   nd=min(v,cnt)
   ans+=nd*s
   cnt-=nd
print(ans)