n, m = map(int, input().split())
a = sorted([int(i) for i in input().split()])
bc = sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x: x[1], reverse=True)
i = 0
for b, c in bc:
    while b:
        if i < n and a[i] < c:
            a[i] = c
            b -= 1
        else:
            break
        i += 1
print(sum(a)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a = sorted([int(i) for i in input().split()]) a sorted([int(i) for i in input().split()]) sorted [int(i) for i in input().split()] tuple(map(int, input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split bc = sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x: x[1], reverse=True) bc sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x: x[1], reverse=True) sorted [tuple(map(int, input().split())) for i in range(m)] key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True i = 0 i 0 for b, c in bc:
    while b:
        if i < n and a[i] < c:
            a[i] = c
            b -= 1
        else:
            break
        i += 1 b c bc while b:
        if i < n and a[i] < c:
            a[i] = c
            b -= 1
        else:
            break
        i += 1 b if i < n and a[i] < c:
            a[i] = c
            b -= 1
        else:
            break
         i < n and a[i] < c i < n i n a[i] < c a[i] a i c a[i] = c a[i] a i c b -= 1 b 1 break i += 1 i 1 print(sum(a)) print sum(a) sum a b -= 1 1 b bc = sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x: x[1], reverse=True) sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x: x[1], reverse=True) bc m = map(int, input().split()) map(int, input().split()) m i += 1 1 i a = sorted([int(i) for i in input().split()]) sorted([int(i) for i in input().split()]) a i = 0 0 i n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
a = sorted([int(i) for i in input().split()])
bc = sorted([tuple(map(int, input().split())) for i in range(m)], key=lambda x: x[1], reverse=True)
i = 0
for b, c in bc:
    while b:
        if i < n and a[i] < c:
            a[i] = c
            b -= 1
        else:
            break
        i += 1
print(sum(a))