import bisect
import itertools

N, M  = map(int,input().split())
A = sorted(list(map(int,input().split())))
D = []

for i in range(M):
    B, C = map(int,input().split())
    D.append((B,C))

D.sort(key = lambda x:x[1],reverse = True)

cnt = 0
ans = []
for b, c in D:
    for i in range(b):
        ans.append(c)
    cnt += b
    if cnt >=N:
        break
#print(D)
#print(ans)
res = sum(A)
for i in range(min(N,len(ans))):
    if ans[i]-A[i]>0:
        res += ans[i] - A[i]
    else:
        break
print(res) import bisect bisect import itertools itertools 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 D = [] D [] for i in range(M):
    B, C = map(int,input().split())
    D.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 D.append((B,C)) D.append D append (B,C) B C D.sort(key = lambda x:x[1],reverse = True) D.sort D sort key = lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse = True reverse True cnt = 0 cnt 0 ans = [] ans [] for b, c in D:
    for i in range(b):
        ans.append(c)
    cnt += b
    if cnt >=N:
        break
#print(D)
#print(ans) b c D for i in range(b):
        ans.append(c)
     i range(b) range b ans.append(c) ans.append ans append c cnt += b cnt b if cnt >=N:
        break
#print(D)
#print(ans) cnt >=N cnt N break res = sum(A) res sum(A) sum A for i in range(min(N,len(ans))):
    if ans[i]-A[i]>0:
        res += ans[i] - A[i]
    else:
        break i range(min(N,len(ans))) range min(N,len(ans)) min N len(ans) len ans if ans[i]-A[i]>0:
        res += ans[i] - A[i]
    else:
        break ans[i]-A[i]>0 ans[i]-A[i] ans[i] ans i A[i] A i 0 res += ans[i] - A[i] res ans[i] - A[i] ans[i] ans i A[i] A i break print(res) print res N, M  = map(int,input().split()) map(int,input().split()) N D = [] [] D M  = map(int,input().split()) map(int,input().split()) M B, C = map(int,input().split()) map(int,input().split()) B cnt = 0 0 cnt ans = [] [] ans cnt += b b cnt res = sum(A) sum(A) res C = map(int,input().split()) map(int,input().split()) C A = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) A res += ans[i] - A[i] ans[i] - A[i] res
import bisect
import itertools

N, M  = map(int,input().split())
A = sorted(list(map(int,input().split())))
D = []

for i in range(M):
    B, C = map(int,input().split())
    D.append((B,C))

D.sort(key = lambda x:x[1],reverse = True)

cnt = 0
ans = []
for b, c in D:
    for i in range(b):
        ans.append(c)
    cnt += b
    if cnt >=N:
        break
#print(D)
#print(ans)
res = sum(A)
for i in range(min(N,len(ans))):
    if ans[i]-A[i]>0:
        res += ans[i] - A[i]
    else:
        break
print(res)