N, M = map(int, input().split())

g_cards = list(map(int, input().split()))

# key-valueデータで管理
dict_cards = []
for card in g_cards:
	dict_cards.append([card, 1])

# 操作
for i in range(M):
	# sizeと同じ枚数のカードが増えたと考える
	size, val = map(int, input().split())
	dict_cards.append([val, size])

# 降順にする
s_dict_cards = sorted(dict_cards, key=lambda x: -x[0])

s_cards = []
for data in s_dict_cards:
	s_cards += [data[0]] * data[1]
	if(len(s_cards) >= N):
		break
# 出力
sum_val = sum(s_cards[:N])
print(sum_val) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M g_cards = list(map(int, input().split())) g_cards list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split dict_cards = [] dict_cards [] for card in g_cards:
	dict_cards.append([card, 1])

# 操作 card g_cards dict_cards.append([card, 1]) dict_cards.append dict_cards append [card, 1] card 1 for i in range(M):
	# sizeと同じ枚数のカードが増えたと考える
	size, val = map(int, input().split())
	dict_cards.append([val, size])

# 降順にする i range(M) range M size, val = map(int, input().split()) size map(int, input().split()) map int input().split() ().split () input split val dict_cards.append([val, size]) dict_cards.append dict_cards append [val, size] val size s_dict_cards = sorted(dict_cards, key=lambda x: -x[0]) s_dict_cards sorted(dict_cards, key=lambda x: -x[0]) sorted dict_cards key=lambda x: -x[0] key lambda x: -x[0] -x[0] x[0] x 0 x s_cards = [] s_cards [] for data in s_dict_cards:
	s_cards += [data[0]] * data[1]
	if(len(s_cards) >= N):
		break
# 出力 data s_dict_cards s_cards += [data[0]] * data[1] s_cards [data[0]] * data[1] [data[0]] data[0] data 0 data[1] data 1 if(len(s_cards) >= N):
		break
# 出力 len(s_cards) >= N len(s_cards) len s_cards N break sum_val = sum(s_cards[:N]) sum_val sum(s_cards[:N]) sum s_cards[:N] s_cards :N N print(sum_val) print sum_val sum_val = sum(s_cards[:N]) sum(s_cards[:N]) sum_val s_cards = [] [] s_cards M = map(int, input().split()) map(int, input().split()) M val = map(int, input().split()) map(int, input().split()) val g_cards = list(map(int, input().split())) list(map(int, input().split())) g_cards s_dict_cards = sorted(dict_cards, key=lambda x: -x[0]) sorted(dict_cards, key=lambda x: -x[0]) s_dict_cards s_cards += [data[0]] * data[1] [data[0]] * data[1] s_cards size, val = map(int, input().split()) map(int, input().split()) size dict_cards = [] [] dict_cards N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())

g_cards = list(map(int, input().split()))

# key-valueデータで管理
dict_cards = []
for card in g_cards:
	dict_cards.append([card, 1])

# 操作
for i in range(M):
	# sizeと同じ枚数のカードが増えたと考える
	size, val = map(int, input().split())
	dict_cards.append([val, size])

# 降順にする
s_dict_cards = sorted(dict_cards, key=lambda x: -x[0])

s_cards = []
for data in s_dict_cards:
	s_cards += [data[0]] * data[1]
	if(len(s_cards) >= N):
		break
# 出力
sum_val = sum(s_cards[:N])
print(sum_val)