#D
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))
bc.sort(key=lambda x:-x[1])
heapq.heapify(a)
for i in range(m):
    b,c = bc[i][0],bc[i][1]
    for j in range(b):
        p = heapq.heappop(a)
        if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
            
print(sum(a)) import heapq heapq 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 bc = [] bc [] for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c)) i range(m) range m b,c = map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c bc.append((b,c)) bc.append bc append (b,c) b c bc.sort(key=lambda x:-x[1]) bc.sort bc sort key=lambda x:-x[1] key lambda x:-x[1] -x[1] x[1] x 1 x heapq.heapify(a) heapq.heapify heapq heapify a for i in range(m):
    b,c = bc[i][0],bc[i][1]
    for j in range(b):
        p = heapq.heappop(a)
        if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
             i range(m) range m b,c = bc[i][0],bc[i][1] b bc[i][0] [i] bc i 0 c bc[i][1] [i] bc i 1 for j in range(b):
        p = heapq.heappop(a)
        if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
             j range(b) range b p = heapq.heappop(a) p heapq.heappop(a) heapq.heappop heapq heappop a if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
             c > p c p heapq.heappush(a,c) heapq.heappush heapq heappush a c heapq.heappush(a,p) heapq.heappush heapq heappush a p break print(sum(a)) print sum(a) sum a bc = [] [] bc m = map(int,input().split()) map(int,input().split()) m b,c = bc[i][0],bc[i][1] bc[i][0] b a = list(map(int,input().split())) list(map(int,input().split())) a p = heapq.heappop(a) heapq.heappop(a) p b,c = map(int,input().split()) map(int,input().split()) b c = bc[i][0],bc[i][1] bc[i][1] c n,m = map(int,input().split()) map(int,input().split()) n c = map(int,input().split()) map(int,input().split()) c
#D
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))
bc.sort(key=lambda x:-x[1])
heapq.heapify(a)
for i in range(m):
    b,c = bc[i][0],bc[i][1]
    for j in range(b):
        p = heapq.heappop(a)
        if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
            
print(sum(a))