N, M = map(int, input().split())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1

for i in range(M):
    B, C = map(int, input().split())
    if C in D:
        D[C] += B
    else:
        D[C] = B

K = sorted(D.keys(), reverse=True)
ans = 0
cnt = N
for k in K:
   a = min(D[k], cnt)
   ans += k * a
   cnt -= a
   if cnt == 0: break
print(ans) 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 D = {} D {} for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1 a A if a in D:
        D[a] += 1
    else:
        D[a] = 1 a in D a D D[a] += 1 D[a] D a 1 D[a] = 1 D[a] D a 1 for i in range(M):
    B, C = map(int, input().split())
    if C in D:
        D[C] += B
    else:
        D[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 if C in D:
        D[C] += B
    else:
        D[C] = B C in D C D D[C] += B D[C] D C B D[C] = B D[C] D C B K = sorted(D.keys(), reverse=True) K sorted(D.keys(), reverse=True) sorted D.keys() D.keys D keys reverse=True reverse True ans = 0 ans 0 cnt = N cnt N for k in K:
   a = min(D[k], cnt)
   ans += k * a
   cnt -= a
   if cnt == 0: break k K a = min(D[k], cnt) a min(D[k], cnt) min D[k] D k cnt ans += k * a ans k * a k a cnt -= a cnt a if cnt == 0: br cnt == 0 cnt 0 print(ans) print ans A = list(map(int, input().split())) list(map(int, input().split())) A D = {} {} D C = map(int, input().split()) map(int, input().split()) C cnt = N N cnt B, C = map(int, input().split()) map(int, input().split()) B K = sorted(D.keys(), reverse=True) sorted(D.keys(), reverse=True) K ans += k * a k * a ans ans = 0 0 ans M = map(int, input().split()) map(int, input().split()) M cnt -= a a cnt a = min(D[k], cnt) min(D[k], cnt) a N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = {}
for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1

for i in range(M):
    B, C = map(int, input().split())
    if C in D:
        D[C] += B
    else:
        D[C] = B

K = sorted(D.keys(), reverse=True)
ans = 0
cnt = N
for k in K:
   a = min(D[k], cnt)
   ans += k * a
   cnt -= a
   if cnt == 0: break
print(ans)