#!/usr/bin/env python3
n, m = map(int, input().split())
(*a, ) = map(int, input().split())
a.sort()
q = [[*map(int, input().split())] for _ in range(m)]
q.sort(key=lambda x: -x[1])
idx = 0
for b, c in q:
    for _ in range(b):
        if idx >= n or a[idx] >= c:
            print(sum(a))
            exit()
        a[idx] = c
        idx += 1
print(sum(a)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m (*a, ) = map(int, input().split()) *a a map(int, input().split()) map int input().split() ().split () input split a.sort() a.sort a sort [*map(int, input().split())] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [*map(int, input().split())] *map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split q = [[*map(int, input().split())] for _ in range(m)] q [[*map(int, input().split())] for _ in range(m)] q.sort(key=lambda x: -x[1]) q.sort q sort key=lambda x: -x[1] key lambda x: -x[1] -x[1] x[1] x 1 x idx = 0 idx 0 for b, c in q:
    for _ in range(b):
        if idx >= n or a[idx] >= c:
            print(sum(a))
            exit()
        a[idx] = c
        idx += 1 b c q for _ in range(b):
        if idx >= n or a[idx] >= c:
            print(sum(a))
            exit()
        a[idx] = c
        idx += 1 _ range(b) range b if idx >= n or a[idx] >= c:
            print(sum(a))
            exit()
         idx >= n or a[idx] >= c idx >= n idx n a[idx] >= c a[idx] a idx c print(sum(a)) print sum(a) sum a exit() exit a[idx] = c a[idx] a idx c idx += 1 idx 1 print(sum(a)) print sum(a) sum a q = [[*map(int, input().split())] for _ in range(m)] [[*map(int, input().split())] for _ in range(m)] q n, m = map(int, input().split()) map(int, input().split()) n idx += 1 1 idx m = map(int, input().split()) map(int, input().split()) m idx = 0 0 idx
#!/usr/bin/env python3
n, m = map(int, input().split())
(*a, ) = map(int, input().split())
a.sort()
q = [[*map(int, input().split())] for _ in range(m)]
q.sort(key=lambda x: -x[1])
idx = 0
for b, c in q:
    for _ in range(b):
        if idx >= n or a[idx] >= c:
            print(sum(a))
            exit()
        a[idx] = c
        idx += 1
print(sum(a))
