N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
list = []
for bc in BC:
    for _ in range(bc[0]):
        list.append(bc[1])
        if len(list) == N:
            break
    else:
        continue
    break
#print(list)
#for i in range(1, N):
#    A[i] += A[i-1]
#for i in range(1, len(list)):
#    list[i] += list[i-1]
for i in range(min(N, len(list))):
    if A[i] >= list[i]:
        break
    A[i] = list[i]
print(sum(A))
 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = sorted(list(map(int, input().split()))) A sorted(list(map(int, input().split()))) sorted list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 BC = [] BC [] for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c)) i range(M) range M b, c = map(int, input().split()) b map(int, input().split()) map int input().split() ().split () input split c BC.append((b, c)) BC.append BC append (b, c) b c BC = sorted(BC, key=lambda x: x[1], reverse=True) BC sorted(BC, key=lambda x: x[1], reverse=True) sorted BC key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True list = [] list [] for bc in BC:
    for _ in range(bc[0]):
        list.append(bc[1])
        if len(list) == N:
            break
    else:
        continue
    break
#print(list)
#for i in range(1, N):
#    A[i] += A[i-1]
#for i in range(1, len(list)):
#    list[i] += list[i-1] bc BC for _ in range(bc[0]):
        list.append(bc[1])
        if len(list) == N:
            break
    else:
        continue
     _ range(bc[0]) range bc[0] bc 0 list.append(bc[1]) list.append list append bc[1] bc 1 if len(list) == N:
            break
     len(list) == N len(list) len list N break continue break for i in range(min(N, len(list))):
    if A[i] >= list[i]:
        break
    A[i] = list[i] i range(min(N, len(list))) range min(N, len(list)) min N len(list) len list if A[i] >= list[i]:
        break
     A[i] >= list[i] A[i] A i list[i] list i break A[i] = list[i] A[i] A i list[i] list i print(sum(A)) print sum(A) sum A ans = 0 0 ans BC = sorted(BC, key=lambda x: x[1], reverse=True) sorted(BC, key=lambda x: x[1], reverse=True) BC A = sorted(list(map(int, input().split()))) sorted(list(map(int, input().split()))) A BC = [] [] BC c = map(int, input().split()) map(int, input().split()) c N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M b, c = map(int, input().split()) map(int, input().split()) b list = [] [] list
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ans = 0
BC = []
for i in range(M):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
list = []
for bc in BC:
    for _ in range(bc[0]):
        list.append(bc[1])
        if len(list) == N:
            break
    else:
        continue
    break
#print(list)
#for i in range(1, N):
#    A[i] += A[i-1]
#for i in range(1, len(list)):
#    list[i] += list[i-1]
for i in range(min(N, len(list))):
    if A[i] >= list[i]:
        break
    A[i] = list[i]
print(sum(A))

