# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

cnt = 0
for l in B_C:
    for i in range(l[0]):
        A.append(l[1])
        cnt += 1
        if cnt > N:
            break
    else:
        continue
    break

A = sorted(A, reverse=True)

print(sum(A[:N])) 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 list(map(int,input().split())) for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split B_C = [list(map(int,input().split())) for _ in range(M)] B_C [list(map(int,input().split())) for _ in range(M)] B_C = sorted(B_C, reverse=True, key=lambda x:x[1]) B_C sorted(B_C, reverse=True, key=lambda x:x[1]) sorted B_C reverse=True reverse True key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x cnt = 0 cnt 0 for l in B_C:
    for i in range(l[0]):
        A.append(l[1])
        cnt += 1
        if cnt > N:
            break
    else:
        continue
    break l B_C for i in range(l[0]):
        A.append(l[1])
        cnt += 1
        if cnt > N:
            break
    else:
        continue
     i range(l[0]) range l[0] l 0 A.append(l[1]) A.append A append l[1] l 1 cnt += 1 cnt 1 if cnt > N:
            break
     cnt > N cnt N break continue 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 cnt += 1 1 cnt M = map(int, input().split()) map(int, input().split()) M A = list(map(int, input().split())) list(map(int, input().split())) A A = sorted(A, reverse=True) sorted(A, reverse=True) A B_C = [list(map(int,input().split())) for _ in range(M)] [list(map(int,input().split())) for _ in range(M)] B_C B_C = sorted(B_C, reverse=True, key=lambda x:x[1]) sorted(B_C, reverse=True, key=lambda x:x[1]) B_C cnt = 0 0 cnt N, M = map(int, input().split()) map(int, input().split()) N
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

cnt = 0
for l in B_C:
    for i in range(l[0]):
        A.append(l[1])
        cnt += 1
        if cnt > N:
            break
    else:
        continue
    break

A = sorted(A, reverse=True)

print(sum(A[:N]))