"""
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
配列サイズの無駄を減らした。m回の操作の際に入力をそのまま受け取る。
"""
n, m = map(int, input().split())
a = list(map(int, input().split()))

num_map = []
for i in range(n):
    num = a[i]
    num_map.append([num, 1])


for i in range(m):
    card_num, num = map(int, input().split())
    num_map.append([num, card_num])

num_map.sort(reverse=True)

rest_card = n
res_sum = 0
for i in range(len(num_map)):
    num, card_num = num_map[i]
    can_use = min(card_num, rest_card)
    rest_card -= can_use
    res_sum += num * can_use

    if rest_card == 0:
        break

print(res_sum) """
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
配列サイズの無駄を減らした。m回の操作の際に入力をそのまま受け取る。
""" 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 num_map = [] num_map [] for i in range(n):
    num = a[i]
    num_map.append([num, 1]) i range(n) range n num = a[i] num a[i] a i num_map.append([num, 1]) num_map.append num_map append [num, 1] num 1 for i in range(m):
    card_num, num = map(int, input().split())
    num_map.append([num, card_num]) i range(m) range m card_num, num = map(int, input().split()) card_num map(int, input().split()) map int input().split() ().split () input split num num_map.append([num, card_num]) num_map.append num_map append [num, card_num] num card_num num_map.sort(reverse=True) num_map.sort num_map sort reverse=True reverse True rest_card = n rest_card n res_sum = 0 res_sum 0 for i in range(len(num_map)):
    num, card_num = num_map[i]
    can_use = min(card_num, rest_card)
    rest_card -= can_use
    res_sum += num * can_use

    if rest_card == 0:
        break i range(len(num_map)) range len(num_map) len num_map num, card_num = num_map[i] num num_map[i] num_map i card_num can_use = min(card_num, rest_card) can_use min(card_num, rest_card) min card_num rest_card rest_card -= can_use rest_card can_use res_sum += num * can_use res_sum num * can_use num can_use if rest_card == 0:
        break rest_card == 0 rest_card 0 break print(res_sum) print res_sum card_num = num_map[i] num_map[i] card_num num_map = [] [] num_map num, card_num = num_map[i] num_map[i] num can_use = min(card_num, rest_card) min(card_num, rest_card) can_use res_sum += num * can_use num * can_use res_sum rest_card = n n rest_card num = map(int, input().split()) map(int, input().split()) num res_sum = 0 0 res_sum m = map(int, input().split()) map(int, input().split()) m a = list(map(int, input().split())) list(map(int, input().split())) a num = a[i] a[i] num n, m = map(int, input().split()) map(int, input().split()) n card_num, num = map(int, input().split()) map(int, input().split()) card_num rest_card -= can_use can_use rest_card
"""
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
配列サイズの無駄を減らした。m回の操作の際に入力をそのまま受け取る。
"""
n, m = map(int, input().split())
a = list(map(int, input().split()))

num_map = []
for i in range(n):
    num = a[i]
    num_map.append([num, 1])


for i in range(m):
    card_num, num = map(int, input().split())
    num_map.append([num, card_num])

num_map.sort(reverse=True)

rest_card = n
res_sum = 0
for i in range(len(num_map)):
    num, card_num = num_map[i]
    can_use = min(card_num, rest_card)
    rest_card -= can_use
    res_sum += num * can_use

    if rest_card == 0:
        break

print(res_sum)