from collections import defaultdict

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

num_dict = defaultdict(int)
for a in a_list:
    num_dict[a] += 1
for _ in range(M):
    b, c = map(int, input().split())
    num_dict[c] += b

ans = 0
num_list = sorted(num_dict.items(), key=lambda x: x[0], reverse=True)

for num, cnt in num_list:
    for _ in range(cnt):
        ans += num
        N -= 1
        if N == 0:
            print(ans)
            exit() from collections import defaultdict N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M a_list = list(map(int, input().split())) a_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split num_dict = defaultdict(int) num_dict defaultdict(int) defaultdict int for a in a_list:
    num_dict[a] += 1 a a_list num_dict[a] += 1 num_dict[a] num_dict a 1 for _ in range(M):
    b, c = map(int, input().split())
    num_dict[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_dict[c] += b num_dict[c] num_dict c b ans = 0 ans 0 num_list = sorted(num_dict.items(), key=lambda x: x[0], reverse=True) num_list sorted(num_dict.items(), key=lambda x: x[0], reverse=True) sorted num_dict.items() num_dict.items num_dict items key=lambda x: x[0] key lambda x: x[0] x[0] x 0 x reverse=True reverse True for num, cnt in num_list:
    for _ in range(cnt):
        ans += num
        N -= 1
        if N == 0:
            print(ans)
            exit() num cnt num_list for _ in range(cnt):
        ans += num
        N -= 1
        if N == 0:
            print(ans)
            exit() _ range(cnt) range cnt ans += num ans num N -= 1 N 1 if N == 0:
            print(ans)
            exit() N == 0 N 0 print(ans) print ans exit() exit num_dict = defaultdict(int) defaultdict(int) num_dict ans = 0 0 ans N -= 1 1 N num_list = sorted(num_dict.items(), key=lambda x: x[0], reverse=True) sorted(num_dict.items(), key=lambda x: x[0], reverse=True) num_list b, c = map(int, input().split()) map(int, input().split()) b c = map(int, input().split()) map(int, input().split()) c ans += num num ans M = map(int, input().split()) map(int, input().split()) M a_list = list(map(int, input().split())) list(map(int, input().split())) a_list N, M = map(int, input().split()) map(int, input().split()) N
from collections import defaultdict

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

num_dict = defaultdict(int)
for a in a_list:
    num_dict[a] += 1
for _ in range(M):
    b, c = map(int, input().split())
    num_dict[c] += b

ans = 0
num_list = sorted(num_dict.items(), key=lambda x: x[0], reverse=True)

for num, cnt in num_list:
    for _ in range(cnt):
        ans += num
        N -= 1
        if N == 0:
            print(ans)
            exit()