N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for m in range(M)]
BC = sorted(BC,key=lambda x:x[1])[::-1]

for b,c in BC:
  A.extend(b*[c])
  if 2*N<len(A):
    break

A = sorted(A)[::-1]
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 m in range(M) for m in range(M) m range(M) range M for m in range(M) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split BC = [list(map(int,input().split())) for m in range(M)] BC [list(map(int,input().split())) for m in range(M)] BC = sorted(BC,key=lambda x:x[1])[::-1] BC sorted(BC,key=lambda x:x[1])[::-1] (BC,key=lambda x:x[1]) sorted BC key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x ::-1 -1 for b,c in BC:
  A.extend(b*[c])
  if 2*N<len(A):
    break b c BC A.extend(b*[c]) A.extend A extend b*[c] b [c] c if 2*N<len(A):
    break 2*N<len(A) 2*N 2 N len(A) len A break A = sorted(A)[::-1] A sorted(A)[::-1] (A) sorted A ::-1 -1 print(sum(A[:N])) print sum(A[:N]) sum A[:N] A :N N BC = [list(map(int,input().split())) for m in range(M)] [list(map(int,input().split())) for m in range(M)] BC M = map(int,input().split()) map(int,input().split()) M A = sorted(A)[::-1] sorted(A)[::-1] A BC = sorted(BC,key=lambda x:x[1])[::-1] sorted(BC,key=lambda x:x[1])[::-1] BC A = list(map(int,input().split())) list(map(int,input().split())) A N,M = map(int,input().split()) map(int,input().split()) N
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for m in range(M)]
BC = sorted(BC,key=lambda x:x[1])[::-1]

for b,c in BC:
  A.extend(b*[c])
  if 2*N<len(A):
    break

A = sorted(A)[::-1]
print(sum(A[:N]))