from collections import Counter


n, m = map(int, input().split())
a = list(map(int, input().split()))
x = Counter(a)

for i in range(m):
    b, c = map(int, input().split())
    x[c] += b

y = list(zip(x.keys(), x.values()))
y.sort(reverse=True)

ans = 0
k = 0
for z in y:
    if k + z[1] <= n:
        ans += z[0] * z[1]
        k += z[1]
    else:
        ans += z[0] * (n - k)
        k = n
        break
print(ans) from collections import Counter 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 x = Counter(a) x Counter(a) Counter a for i in range(m):
    b, c = map(int, input().split())
    x[c] += b i range(m) range m b, c = map(int, input().split()) b map(int, input().split()) map int input().split() ().split () input split c x[c] += b x[c] x c b y = list(zip(x.keys(), x.values())) y list(zip(x.keys(), x.values())) list zip(x.keys(), x.values()) zip x.keys() x.keys x keys x.values() x.values x values y.sort(reverse=True) y.sort y sort reverse=True reverse True ans = 0 ans 0 k = 0 k 0 for z in y:
    if k + z[1] <= n:
        ans += z[0] * z[1]
        k += z[1]
    else:
        ans += z[0] * (n - k)
        k = n
        break z y if k + z[1] <= n:
        ans += z[0] * z[1]
        k += z[1]
    else:
        ans += z[0] * (n - k)
        k = n
        break k + z[1] <= n k + z[1] k z[1] z 1 n ans += z[0] * z[1] ans z[0] * z[1] z[0] z 0 z[1] z 1 k += z[1] k z[1] z 1 ans += z[0] * (n - k) ans z[0] * (n - k) z[0] z 0 n - k n k k = n k n break print(ans) print ans y = list(zip(x.keys(), x.values())) list(zip(x.keys(), x.values())) y b, c = map(int, input().split()) map(int, input().split()) b a = list(map(int, input().split())) list(map(int, input().split())) a k = 0 0 k k += z[1] z[1] k c = map(int, input().split()) map(int, input().split()) c ans = 0 0 ans ans += z[0] * (n - k) z[0] * (n - k) ans k = n n k n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m x = Counter(a) Counter(a) x ans += z[0] * z[1] z[0] * z[1] ans
from collections import Counter


n, m = map(int, input().split())
a = list(map(int, input().split()))
x = Counter(a)

for i in range(m):
    b, c = map(int, input().split())
    x[c] += b

y = list(zip(x.keys(), x.values()))
y.sort(reverse=True)

ans = 0
k = 0
for z in y:
    if k + z[1] <= n:
        ans += z[0] * z[1]
        k += z[1]
    else:
        ans += z[0] * (n - k)
        k = n
        break
print(ans)
