n,m = map(int, input().split())
num_cnts = []
al = list(map(int, input().split()))
for a in al:
    num_cnts.append((a,1))

for _ in range(m):
    b,c = map(int, input().split())
    num_cnts.append((c,b))

num_cnts.sort(reverse=True)
ans = 0
curr_cnt = 0
for num,cnt in num_cnts:
    if curr_cnt + cnt <= n:
        ans += num*cnt
        curr_cnt += cnt
    else:
        rem = n-curr_cnt
        ans += rem*num
        break

print(ans) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m num_cnts = [] num_cnts [] al = list(map(int, input().split())) al list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for a in al:
    num_cnts.append((a,1)) a al num_cnts.append((a,1)) num_cnts.append num_cnts append (a,1) a 1 for _ in range(m):
    b,c = map(int, input().split())
    num_cnts.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 num_cnts.append((c,b)) num_cnts.append num_cnts append (c,b) c b num_cnts.sort(reverse=True) num_cnts.sort num_cnts sort reverse=True reverse True ans = 0 ans 0 curr_cnt = 0 curr_cnt 0 for num,cnt in num_cnts:
    if curr_cnt + cnt <= n:
        ans += num*cnt
        curr_cnt += cnt
    else:
        rem = n-curr_cnt
        ans += rem*num
        break num cnt num_cnts if curr_cnt + cnt <= n:
        ans += num*cnt
        curr_cnt += cnt
    else:
        rem = n-curr_cnt
        ans += rem*num
        break curr_cnt + cnt <= n curr_cnt + cnt curr_cnt cnt n ans += num*cnt ans num*cnt num cnt curr_cnt += cnt curr_cnt cnt rem = n-curr_cnt rem n-curr_cnt n curr_cnt ans += rem*num ans rem*num rem num break print(ans) print ans curr_cnt = 0 0 curr_cnt ans += rem*num rem*num ans num_cnts = [] [] num_cnts ans = 0 0 ans curr_cnt += cnt cnt curr_cnt ans += num*cnt num*cnt ans n,m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m b,c = map(int, input().split()) map(int, input().split()) b al = list(map(int, input().split())) list(map(int, input().split())) al rem = n-curr_cnt n-curr_cnt rem c = map(int, input().split()) map(int, input().split()) c
n,m = map(int, input().split())
num_cnts = []
al = list(map(int, input().split()))
for a in al:
    num_cnts.append((a,1))

for _ in range(m):
    b,c = map(int, input().split())
    num_cnts.append((c,b))

num_cnts.sort(reverse=True)
ans = 0
curr_cnt = 0
for num,cnt in num_cnts:
    if curr_cnt + cnt <= n:
        ans += num*cnt
        curr_cnt += cnt
    else:
        rem = n-curr_cnt
        ans += rem*num
        break

print(ans)