n,m = map(int,input().split())
ls = list(map(int,input().split()))
di = [list(map(int,input().split())) for _ in range(m)]
fi = []
for i,j in di:
    fi.append([j,i])
for k in ls:
    fi.append([k,1])
fi.sort(reverse=True)
ans = 0
cnt = 0
how = 0
while True:
    if how + fi[cnt][1] < n:
        how += fi[cnt][1]
        ans += fi[cnt][1]*fi[cnt][0]
    else:
        ans += (n-how)*fi[cnt][0]
        break
    cnt += 1
print(ans)
 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m ls = list(map(int,input().split())) ls list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split di = [list(map(int,input().split())) for _ in range(m)] di [list(map(int,input().split())) for _ in range(m)] fi = [] fi [] for i,j in di:
    fi.append([j,i]) i j di fi.append([j,i]) fi.append fi append [j,i] j i for k in ls:
    fi.append([k,1]) k ls fi.append([k,1]) fi.append fi append [k,1] k 1 fi.sort(reverse=True) fi.sort fi sort reverse=True reverse True ans = 0 ans 0 cnt = 0 cnt 0 how = 0 how 0 while True:
    if how + fi[cnt][1] < n:
        how += fi[cnt][1]
        ans += fi[cnt][1]*fi[cnt][0]
    else:
        ans += (n-how)*fi[cnt][0]
        break
    cnt += 1 True if how + fi[cnt][1] < n:
        how += fi[cnt][1]
        ans += fi[cnt][1]*fi[cnt][0]
    else:
        ans += (n-how)*fi[cnt][0]
        break
     how + fi[cnt][1] < n how + fi[cnt][1] how fi[cnt][1] [cnt] fi cnt 1 n how += fi[cnt][1] how fi[cnt][1] [cnt] fi cnt 1 ans += fi[cnt][1]*fi[cnt][0] ans fi[cnt][1]*fi[cnt][0] fi[cnt][1] [cnt] fi cnt 1 fi[cnt][0] [cnt] fi cnt 0 ans += (n-how)*fi[cnt][0] ans (n-how)*fi[cnt][0] n-how n how fi[cnt][0] [cnt] fi cnt 0 break cnt += 1 cnt 1 print(ans) print ans how = 0 0 how n,m = map(int,input().split()) map(int,input().split()) n ans += fi[cnt][1]*fi[cnt][0] fi[cnt][1]*fi[cnt][0] ans ls = list(map(int,input().split())) list(map(int,input().split())) ls cnt += 1 1 cnt ans = 0 0 ans m = map(int,input().split()) map(int,input().split()) m fi = [] [] fi cnt = 0 0 cnt how += fi[cnt][1] fi[cnt][1] how di = [list(map(int,input().split())) for _ in range(m)] [list(map(int,input().split())) for _ in range(m)] di ans += (n-how)*fi[cnt][0] (n-how)*fi[cnt][0] ans
n,m = map(int,input().split())
ls = list(map(int,input().split()))
di = [list(map(int,input().split())) for _ in range(m)]
fi = []
for i,j in di:
    fi.append([j,i])
for k in ls:
    fi.append([k,1])
fi.sort(reverse=True)
ans = 0
cnt = 0
how = 0
while True:
    if how + fi[cnt][1] < n:
        how += fi[cnt][1]
        ans += fi[cnt][1]*fi[cnt][0]
    else:
        ans += (n-how)*fi[cnt][0]
        break
    cnt += 1
print(ans)

