import heapq  # heapqライブラリのimport
N,M=map(int,input().split())
lst=list(map(int,input().split()))
for i in range(N):
 lst[i]=(-lst[i],1)
for i in range(M):
 B,C=map(int,input().split())
 lst.append((-C,B))
heapq.heapify(lst)  # リストを優先度付きキューへ
ans=0
while N>0 :
 a=heapq.heappop(lst)
 ans+=a[0]*a[1]
 N-=a[1] 
ans+=a[0]*N
print((-1)*ans) import heapq heapq N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M lst=list(map(int,input().split())) lst list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in range(N):
 lst[i]=(-lst[i],1) i range(N) range N lst[i]=(-lst[i],1) lst[i] lst i (-lst[i],1) -lst[i] lst[i] lst i 1 for i in range(M):
 B,C=map(int,input().split())
 lst.append((-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 lst.append((-C,B)) lst.append lst append (-C,B) -C C B heapq.heapify(lst) heapq.heapify heapq heapify lst ans=0 ans 0 while N>0 :
 a=heapq.heappop(lst)
 ans+=a[0]*a[1]
 N-=a[1]  N>0 N 0 a=heapq.heappop(lst) a heapq.heappop(lst) heapq.heappop heapq heappop lst ans+=a[0]*a[1] ans a[0]*a[1] a[0] a 0 a[1] a 1 N-=a[1] N a[1] a 1 ans+=a[0]*N ans a[0]*N a[0] a 0 N print((-1)*ans) print (-1)*ans -1 ans M=map(int,input().split()) map(int,input().split()) M N-=a[1] a[1] N ans+=a[0]*N a[0]*N ans ans=0 0 ans N,M=map(int,input().split()) map(int,input().split()) N a=heapq.heappop(lst) heapq.heappop(lst) a lst=list(map(int,input().split())) list(map(int,input().split())) lst ans+=a[0]*a[1] a[0]*a[1] ans C=map(int,input().split()) map(int,input().split()) C B,C=map(int,input().split()) map(int,input().split()) B
import heapq  # heapqライブラリのimport
N,M=map(int,input().split())
lst=list(map(int,input().split()))
for i in range(N):
 lst[i]=(-lst[i],1)
for i in range(M):
 B,C=map(int,input().split())
 lst.append((-C,B))
heapq.heapify(lst)  # リストを優先度付きキューへ
ans=0
while N>0 :
 a=heapq.heappop(lst)
 ans+=a[0]*a[1]
 N-=a[1] 
ans+=a[0]*N
print((-1)*ans)
