"""
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
辞書型に変更。
"""
n, m = map(int, input().split())
a = list(map(int, input().split()))

num_map = dict()
for i in range(n):
    num = a[i]
    if num not in num_map:
        num_map[num] = 1
    else:
        num_map[num] += 1

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

num_map_list = list(num_map.keys())
num_map_list.sort(reverse=True)

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

    if rest_card == 0:
        break

print(res_sum)
 """
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
辞書型に変更。
""" 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 = dict() num_map dict() dict for i in range(n):
    num = a[i]
    if num not in num_map:
        num_map[num] = 1
    else:
        num_map[num] += 1 i range(n) range n num = a[i] num a[i] a i if num not in num_map:
        num_map[num] = 1
    else:
        num_map[num] += 1 num not in num_map num num_map num_map[num] = 1 num_map[num] num_map num 1 num_map[num] += 1 num_map[num] num_map num 1 for i in range(m):
    card_num, num = map(int, input().split())
    if num not in num_map:
        num_map[num] = card_num
    else:
        num_map[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 if num not in num_map:
        num_map[num] = card_num
    else:
        num_map[num] += card_num num not in num_map num num_map num_map[num] = card_num num_map[num] num_map num card_num num_map[num] += card_num num_map[num] num_map num card_num num_map_list = list(num_map.keys()) num_map_list list(num_map.keys()) list num_map.keys() num_map.keys num_map keys num_map_list.sort(reverse=True) num_map_list.sort num_map_list sort reverse=True reverse True rest_card = n rest_card n res_sum = 0 res_sum 0 for i in range(len(num_map_list)):
    num = num_map_list[i]
    some_num = num_map[num]
    can_use = min(some_num, rest_card)
    rest_card -= can_use
    res_sum += num * can_use

    if rest_card == 0:
        break i range(len(num_map_list)) range len(num_map_list) len num_map_list num = num_map_list[i] num num_map_list[i] num_map_list i some_num = num_map[num] some_num num_map[num] num_map num can_use = min(some_num, rest_card) can_use min(some_num, rest_card) min some_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 a = list(map(int, input().split())) list(map(int, input().split())) a rest_card -= can_use can_use rest_card num_map = dict() dict() num_map res_sum = 0 0 res_sum num = num_map_list[i] num_map_list[i] num some_num = num_map[num] num_map[num] some_num m = map(int, input().split()) map(int, input().split()) m n, m = map(int, input().split()) map(int, input().split()) n card_num, num = map(int, input().split()) map(int, input().split()) card_num res_sum += num * can_use num * can_use res_sum num = a[i] a[i] num rest_card = n n rest_card can_use = min(some_num, rest_card) min(some_num, rest_card) can_use num_map_list = list(num_map.keys()) list(num_map.keys()) num_map_list num = map(int, input().split()) map(int, input().split()) num
"""
マッピングに配列を使った場合、配列の大きさが大きすぎて無駄が多かったから
辞書型に変更。
"""
n, m = map(int, input().split())
a = list(map(int, input().split()))

num_map = dict()
for i in range(n):
    num = a[i]
    if num not in num_map:
        num_map[num] = 1
    else:
        num_map[num] += 1

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

num_map_list = list(num_map.keys())
num_map_list.sort(reverse=True)

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

    if rest_card == 0:
        break

print(res_sum)

