n, m = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = 1 if a not in d else d[a] + 1
for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[c] + b
ans = 0
cnt = 0
L = sorted(d, reverse=True)
for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break
print(ans) 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 d = {} d {} for a in A:
    d[a] = 1 if a not in d else d[a] + 1 a A d[a] = 1 if a not in d else d[a] + 1 d[a] d a 1 if a not in d else d[a] + 1 a not in d a d 1 d[a] + 1 d[a] d a 1 for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[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 d[c] = b if c not in d else d[c] + b d[c] d c b if c not in d else d[c] + b c not in d c d b d[c] + b d[c] d c b ans = 0 ans 0 cnt = 0 cnt 0 L = sorted(d, reverse=True) L sorted(d, reverse=True) sorted d reverse=True reverse True for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break k L if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break d[k] + cnt < n d[k] + cnt d[k] d k cnt n ans += k * d[k] ans k * d[k] k d[k] d k cnt += d[k] cnt d[k] d k ans += k * (n - cnt) ans k * (n - cnt) k n - cnt n cnt break print(ans) print ans b, c = map(int, input().split()) map(int, input().split()) b cnt += d[k] d[k] cnt ans += k * (n - cnt) k * (n - cnt) ans m = map(int, input().split()) map(int, input().split()) m ans += k * d[k] k * d[k] ans ans = 0 0 ans cnt = 0 0 cnt c = map(int, input().split()) map(int, input().split()) c n, m = map(int, input().split()) map(int, input().split()) n A = list(map(int, input().split())) list(map(int, input().split())) A L = sorted(d, reverse=True) sorted(d, reverse=True) L d = {} {} d
n, m = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = 1 if a not in d else d[a] + 1
for _ in range(m):
    b, c = map(int, input().split())
    d[c] = b if c not in d else d[c] + b
ans = 0
cnt = 0
L = sorted(d, reverse=True)
for k in L:
    if d[k] + cnt < n:
        ans += k * d[k]
        cnt += d[k]
    else:
        ans += k * (n - cnt)
        break
print(ans)
