import sys
from collections import defaultdict, Counter

input = sys.stdin.readline
N, M = map(int, input().split())
A = (Counter(list(map(int, input().split()))))
for i in range(M):
    B,C=map(int,input().split())
    if C in A:
        A[C] += B
    else:
        A[C] = B
A = sorted(A.items(),reverse=True)
tmp = 0
cnt = 0
ans = 0
while tmp < N:
    i,j = A[cnt]
    ans += min(N-tmp,j)*i
    cnt += 1
    tmp += min(N-tmp,j)
print(ans) import sys sys from collections import defaultdict, Counter input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = (Counter(list(map(int, input().split())))) A Counter(list(map(int, input().split()))) Counter list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for i in range(M):
    B,C=map(int,input().split())
    if C in A:
        A[C] += B
    else:
        A[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 A:
        A[C] += B
    else:
        A[C] = B C in A C A A[C] += B A[C] A C B A[C] = B A[C] A C B A = sorted(A.items(),reverse=True) A sorted(A.items(),reverse=True) sorted A.items() A.items A items reverse=True reverse True tmp = 0 tmp 0 cnt = 0 cnt 0 ans = 0 ans 0 while tmp < N:
    i,j = A[cnt]
    ans += min(N-tmp,j)*i
    cnt += 1
    tmp += min(N-tmp,j) tmp < N tmp N i,j = A[cnt] i A[cnt] A cnt j ans += min(N-tmp,j)*i ans min(N-tmp,j)*i min(N-tmp,j) min N-tmp N tmp j i cnt += 1 cnt 1 tmp += min(N-tmp,j) tmp min(N-tmp,j) min N-tmp N tmp j print(ans) print ans ans += min(N-tmp,j)*i min(N-tmp,j)*i ans tmp += min(N-tmp,j) min(N-tmp,j) tmp cnt = 0 0 cnt tmp = 0 0 tmp M = map(int, input().split()) map(int, input().split()) M B,C=map(int,input().split()) map(int,input().split()) B i,j = A[cnt] A[cnt] i j = A[cnt] A[cnt] j A = (Counter(list(map(int, input().split())))) Counter(list(map(int, input().split()))) A cnt += 1 1 cnt input = sys.stdin.readline sys.stdin.readline input N, M = map(int, input().split()) map(int, input().split()) N A = sorted(A.items(),reverse=True) sorted(A.items(),reverse=True) A C=map(int,input().split()) map(int,input().split()) C ans = 0 0 ans
import sys
from collections import defaultdict, Counter

input = sys.stdin.readline
N, M = map(int, input().split())
A = (Counter(list(map(int, input().split()))))
for i in range(M):
    B,C=map(int,input().split())
    if C in A:
        A[C] += B
    else:
        A[C] = B
A = sorted(A.items(),reverse=True)
tmp = 0
cnt = 0
ans = 0
while tmp < N:
    i,j = A[cnt]
    ans += min(N-tmp,j)*i
    cnt += 1
    tmp += min(N-tmp,j)
print(ans)