import sys
input = sys.stdin.readline

n,m = map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split())) for i in range(m)]
BC = sorted(BC,key=lambda x:-x[1])
cnt = 0
flag = True
while True:
    for b,c in BC:
        A += [c]*b
        cnt += b
        if cnt > n:
            break
    break
A = sorted(A,reverse=True)
print(sum(A[:n])) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 tuple(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) tuple(map(int,input().split())) tuple map(int,input().split()) map int input().split() ().split () input split BC = [tuple(map(int,input().split())) for i in range(m)] BC [tuple(map(int,input().split())) for i in range(m)] BC = sorted(BC,key=lambda x:-x[1]) BC sorted(BC,key=lambda x:-x[1]) sorted BC key=lambda x:-x[1] key lambda x:-x[1] -x[1] x[1] x 1 x cnt = 0 cnt 0 flag = True flag True while True:
    for b,c in BC:
        A += [c]*b
        cnt += b
        if cnt > n:
            break
    break True for b,c in BC:
        A += [c]*b
        cnt += b
        if cnt > n:
            break
     b c BC A += [c]*b A [c]*b [c] c b cnt += b cnt b if cnt > n:
            break
     cnt > n cnt n break break A = sorted(A,reverse=True) A sorted(A,reverse=True) sorted A reverse=True reverse True print(sum(A[:n])) print sum(A[:n]) sum A[:n] A :n n A = list(map(int,input().split())) list(map(int,input().split())) A input = sys.stdin.readline sys.stdin.readline input A += [c]*b [c]*b A BC = sorted(BC,key=lambda x:-x[1]) sorted(BC,key=lambda x:-x[1]) BC flag = True True flag cnt = 0 0 cnt m = map(int,input().split()) map(int,input().split()) m cnt += b b cnt n,m = map(int,input().split()) map(int,input().split()) n BC = [tuple(map(int,input().split())) for i in range(m)] [tuple(map(int,input().split())) for i in range(m)] BC A = sorted(A,reverse=True) sorted(A,reverse=True) A
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split())) for i in range(m)]
BC = sorted(BC,key=lambda x:-x[1])
cnt = 0
flag = True
while True:
    for b,c in BC:
        A += [c]*b
        cnt += b
        if cnt > n:
            break
    break
A = sorted(A,reverse=True)
print(sum(A[:n]))