from operator import itemgetter

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 = itemgetter(1),reverse=True)

change = []
for b,c in BC:
    change += [c] * b
    if len(change) > N:
        break
A += change
A.sort(reverse=True)
answer = sum(A[:N])
print(answer) from operator import itemgetter 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 = itemgetter(1),reverse=True) BC.sort BC sort key = itemgetter(1) key itemgetter(1) itemgetter 1 reverse=True reverse True change = [] change [] for b,c in BC:
    change += [c] * b
    if len(change) > N:
        break b c BC change += [c] * b change [c] * b [c] c b if len(change) > N:
        break len(change) > N len(change) len change N break A += change A change A.sort(reverse=True) A.sort A sort reverse=True reverse True answer = sum(A[:N]) answer sum(A[:N]) sum A[:N] A :N N print(answer) print answer C = map(int,input().split()) map(int,input().split()) C M = map(int,input().split()) map(int,input().split()) M A += change change A BC = [] [] BC change += [c] * b [c] * b change answer = sum(A[:N]) sum(A[:N]) answer N,M = map(int,input().split()) map(int,input().split()) N B,C = map(int,input().split()) map(int,input().split()) B change = [] [] change A = list(map(int,input().split())) list(map(int,input().split())) A
from operator import itemgetter

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 = itemgetter(1),reverse=True)

change = []
for b,c in BC:
    change += [c] * b
    if len(change) > N:
        break
A += change
A.sort(reverse=True)
answer = sum(A[:N])
print(answer)