N, M = map(int,input().split())

A = list(map(int,input().split()))
D = dict()

for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1

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

D = sorted(D.items(), reverse = True)

ans, cnt = 0, 0
for d in D:
    x = min(d[1], N-cnt)
    cnt += x
    ans += d[0] * x

    if cnt == N: 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 = dict() D dict() dict 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 _ in range(M):
    B, C = map(int,input().split())
    if C in D:
        D[C] += B
    else:
        D[C] = B _ 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 D = sorted(D.items(), reverse = True) D sorted(D.items(), reverse = True) sorted D.items() D.items D items reverse = True reverse True ans, cnt = 0, 0 ans 0 cnt 0 for d in D:
    x = min(d[1], N-cnt)
    cnt += x
    ans += d[0] * x

    if cnt == N: break d D x = min(d[1], N-cnt) x min(d[1], N-cnt) min d[1] d 1 N-cnt N cnt cnt += x cnt x ans += d[0] * x ans d[0] * x d[0] d 0 x if cnt == N: b cnt == N cnt N print(ans) print ans C = map(int,input().split()) map(int,input().split()) C M = map(int,input().split()) map(int,input().split()) M ans, cnt = 0, 0 0 ans cnt += x x cnt B, C = map(int,input().split()) map(int,input().split()) B cnt = 0, 0 0 cnt D = dict() dict() D x = min(d[1], N-cnt) min(d[1], N-cnt) x N, M = map(int,input().split()) map(int,input().split()) N D = sorted(D.items(), reverse = True) sorted(D.items(), reverse = True) D ans += d[0] * x d[0] * x ans A = list(map(int,input().split())) list(map(int,input().split())) A
N, M = map(int,input().split())

A = list(map(int,input().split()))
D = dict()

for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1

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

D = sorted(D.items(), reverse = True)

ans, cnt = 0, 0
for d in D:
    x = min(d[1], N-cnt)
    cnt += x
    ans += d[0] * x

    if cnt == N: break


print(ans)
