N,M = map(int,input().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
A.sort(reverse = True)
Q = []
for i in range(M):
    B,C = map(int,input().rstrip().split(" "))
    Q.append([C,B])
Q.sort(reverse = True)

p = 0
j = 0
while p < N and j < M:
    for i in range(Q[j][1]):
        if i + p > N:
            break
        A.append(Q[j][0])
    p += Q[j][1]
    j += 1
ans = 0
A.sort(reverse = True)

for i in range(N):
    ans += A[i]

print(ans) N,M = map(int,input().rstrip().split(" ")) N map(int,input().rstrip().split(" ")) map int input().rstrip().split(" ") ().rstrip().split ().rstrip() ().rstrip () input rstrip split " " M A = list(map(int,input().rstrip().split(" "))) A list(map(int,input().rstrip().split(" "))) list map(int,input().rstrip().split(" ")) map int input().rstrip().split(" ") ().rstrip().split ().rstrip() ().rstrip () input rstrip split " " A.sort(reverse = True) A.sort A sort reverse = True reverse True Q = [] Q [] for i in range(M):
    B,C = map(int,input().rstrip().split(" "))
    Q.append([C,B]) i range(M) range M B,C = map(int,input().rstrip().split(" ")) B map(int,input().rstrip().split(" ")) map int input().rstrip().split(" ") ().rstrip().split ().rstrip() ().rstrip () input rstrip split " " C Q.append([C,B]) Q.append Q append [C,B] C B Q.sort(reverse = True) Q.sort Q sort reverse = True reverse True p = 0 p 0 j = 0 j 0 while p < N and j < M:
    for i in range(Q[j][1]):
        if i + p > N:
            break
        A.append(Q[j][0])
    p += Q[j][1]
    j += 1 p < N and j < M p < N p N j < M j M for i in range(Q[j][1]):
        if i + p > N:
            break
        A.append(Q[j][0])
     i range(Q[j][1]) range Q[j][1] [j] Q j 1 if i + p > N:
            break
         i + p > N i + p i p N break A.append(Q[j][0]) A.append A append Q[j][0] [j] Q j 0 p += Q[j][1] p Q[j][1] [j] Q j 1 j += 1 j 1 ans = 0 ans 0 A.sort(reverse = True) A.sort A sort reverse = True reverse True for i in range(N):
    ans += A[i] i range(N) range N ans += A[i] ans A[i] A i print(ans) print ans p += Q[j][1] Q[j][1] p j += 1 1 j C = map(int,input().rstrip().split(" ")) map(int,input().rstrip().split(" ")) C N,M = map(int,input().rstrip().split(" ")) map(int,input().rstrip().split(" ")) N j = 0 0 j ans = 0 0 ans B,C = map(int,input().rstrip().split(" ")) map(int,input().rstrip().split(" ")) B A = list(map(int,input().rstrip().split(" "))) list(map(int,input().rstrip().split(" "))) A ans += A[i] A[i] ans M = map(int,input().rstrip().split(" ")) map(int,input().rstrip().split(" ")) M p = 0 0 p Q = [] [] Q
N,M = map(int,input().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
A.sort(reverse = True)
Q = []
for i in range(M):
    B,C = map(int,input().rstrip().split(" "))
    Q.append([C,B])
Q.sort(reverse = True)

p = 0
j = 0
while p < N and j < M:
    for i in range(Q[j][1]):
        if i + p > N:
            break
        A.append(Q[j][0])
    p += Q[j][1]
    j += 1
ans = 0
A.sort(reverse = True)

for i in range(N):
    ans += A[i]

print(ans)
