N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
from collections import deque
AA = deque(A)
change = []
for _ in range(M):
    b,c = map(int,input().split())
    change.append((c,b))
change.sort(reverse=True)
import sys
flag = True
for c,b in change:
    for i in range(b):
        a = AA.popleft()
        if a<c:
            AA.append(c)
        else:
            flag = False
            AA.append(a)
            print(sum(AA))
            sys.exit()
if flag:
    print(sum(AA)) 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 A.sort() A.sort A sort from collections import deque AA = deque(A) AA deque(A) deque A change = [] change [] for _ in range(M):
    b,c = map(int,input().split())
    change.append((c,b)) _ range(M) range M b,c = map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c change.append((c,b)) change.append change append (c,b) c b change.sort(reverse=True) change.sort change sort reverse=True reverse True import sys sys flag = True flag True for c,b in change:
    for i in range(b):
        a = AA.popleft()
        if a<c:
            AA.append(c)
        else:
            flag = False
            AA.append(a)
            print(sum(AA))
            sys.exit() c b change for i in range(b):
        a = AA.popleft()
        if a<c:
            AA.append(c)
        else:
            flag = False
            AA.append(a)
            print(sum(AA))
            sys.exit() i range(b) range b a = AA.popleft() a AA.popleft() AA.popleft AA popleft if a<c:
            AA.append(c)
        else:
            flag = False
            AA.append(a)
            print(sum(AA))
            sys.exit() a<c a c AA.append(c) AA.append AA append c flag = False flag False AA.append(a) AA.append AA append a print(sum(AA)) print sum(AA) sum AA sys.exit() sys.exit sys exit if flag:
    print(sum(AA)) flag print(sum(AA)) print sum(AA) sum AA flag = True True flag c = map(int,input().split()) map(int,input().split()) c A = list(map(int,input().split())) list(map(int,input().split())) A M = map(int,input().split()) map(int,input().split()) M a = AA.popleft() AA.popleft() a N,M = map(int,input().split()) map(int,input().split()) N AA = deque(A) deque(A) AA change = [] [] change flag = False False flag b,c = map(int,input().split()) map(int,input().split()) b
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
from collections import deque
AA = deque(A)
change = []
for _ in range(M):
    b,c = map(int,input().split())
    change.append((c,b))
change.sort(reverse=True)
import sys
flag = True
for c,b in change:
    for i in range(b):
        a = AA.popleft()
        if a<c:
            AA.append(c)
        else:
            flag = False
            AA.append(a)
            print(sum(AA))
            sys.exit()
if flag:
    print(sum(AA))