n,m = map(int,input().split())
A = list(map(int,input().split()))
D = [(A[i],1) for i in range(n)]

for i in range(m):
    b,c = map(int,input().split())
    D.append((c,b))

D.sort(reverse = True)

ans, left = 0, n

for (i,j) in D:
    use = min(j, left)
    ans += use * i
    left -= use
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 (A[i],1) for i in range(n) for i in range(n) i range(n) range n for i in range(n) (A[i],1) A[i] A i 1 D = [(A[i],1) for i in range(n)] D [(A[i],1) for i in range(n)] for i in range(m):
    b,c = map(int,input().split())
    D.append((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 D.append((c,b)) D.append D append (c,b) c b D.sort(reverse = True) D.sort D sort reverse = True reverse True ans, left = 0, n ans 0 left n for (i,j) in D:
    use = min(j, left)
    ans += use * i
    left -= use (i,j) i j D use = min(j, left) use min(j, left) min j left ans += use * i ans use * i use i left -= use left use print(ans) print ans n,m = map(int,input().split()) map(int,input().split()) n ans += use * i use * i ans b,c = map(int,input().split()) map(int,input().split()) b m = map(int,input().split()) map(int,input().split()) m A = list(map(int,input().split())) list(map(int,input().split())) A left = 0, n n left use = min(j, left) min(j, left) use c = map(int,input().split()) map(int,input().split()) c ans, left = 0, n 0 ans D = [(A[i],1) for i in range(n)] [(A[i],1) for i in range(n)] D left -= use use left
n,m = map(int,input().split())
A = list(map(int,input().split()))
D = [(A[i],1) for i in range(n)]

for i in range(m):
    b,c = map(int,input().split())
    D.append((c,b))

D.sort(reverse = True)

ans, left = 0, n

for (i,j) in D:
    use = min(j, left)
    ans += use * i
    left -= use
print(ans)