n,m = map(int,input().split())
a = list(map(int,input().split()))
bcl = [list(map(int,input().split())) for nesya in range(m)]
bcl.sort(reverse=True,key=lambda x:x[1])
t = 0
for bc in bcl:
  t += bc[0]
  a += [bc[1]]*bc[0]
  if t > n:
    break
a.sort(reverse=True)
print(sum(a[:n])) 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 list(map(int,input().split())) for nesya in range(m) for nesya in range(m) nesya range(m) range m for nesya in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split bcl = [list(map(int,input().split())) for nesya in range(m)] bcl [list(map(int,input().split())) for nesya in range(m)] bcl.sort(reverse=True,key=lambda x:x[1]) bcl.sort bcl sort reverse=True reverse True key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x t = 0 t 0 for bc in bcl:
  t += bc[0]
  a += [bc[1]]*bc[0]
  if t > n:
    break bc bcl t += bc[0] t bc[0] bc 0 a += [bc[1]]*bc[0] a [bc[1]]*bc[0] [bc[1]] bc[1] bc 1 bc[0] bc 0 if t > n:
    break t > n t n break a.sort(reverse=True) a.sort a sort reverse=True reverse True print(sum(a[:n])) print sum(a[:n]) sum a[:n] a :n n bcl = [list(map(int,input().split())) for nesya in range(m)] [list(map(int,input().split())) for nesya in range(m)] bcl t = 0 0 t t += bc[0] bc[0] t n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m a = list(map(int,input().split())) list(map(int,input().split())) a a += [bc[1]]*bc[0] [bc[1]]*bc[0] a
n,m = map(int,input().split())
a = list(map(int,input().split()))
bcl = [list(map(int,input().split())) for nesya in range(m)]
bcl.sort(reverse=True,key=lambda x:x[1])
t = 0
for bc in bcl:
  t += bc[0]
  a += [bc[1]]*bc[0]
  if t > n:
    break
a.sort(reverse=True)
print(sum(a[:n]))