N,M=map(int,input().split())
A=map(int,input().split())
L=[(1,a) for a in A]
for _ in range(M):
  b,c=map(int,input().split())
  L.append((b,c))
L=sorted(L,key=lambda x: x[1],reverse=True)
ans,k=0,0
for n,a in L:
  if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n
print(ans) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M A=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split (1,a) for a in A for a in A a A for a in A (1,a) 1 a L=[(1,a) for a in A] L [(1,a) for a in A] for _ in range(M):
  b,c=map(int,input().split())
  L.append((b,c)) _ range(M) range M b,c=map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c L.append((b,c)) L.append L append (b,c) b c L=sorted(L,key=lambda x: x[1],reverse=True) L sorted(L,key=lambda x: x[1],reverse=True) sorted L key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True ans,k=0,0 ans 0 k 0 for n,a in L:
  if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n n a L if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n n+k>=N n+k n k N ans+=a*(N-k) ans a*(N-k) a N-k N k break ans+=a*n ans a*n a n k+=n k n print(ans) print ans ans+=a*(N-k) a*(N-k) ans c=map(int,input().split()) map(int,input().split()) c ans+=a*n a*n ans b,c=map(int,input().split()) map(int,input().split()) b N,M=map(int,input().split()) map(int,input().split()) N A=map(int,input().split()) map(int,input().split()) A k+=n n k L=[(1,a) for a in A] [(1,a) for a in A] L ans,k=0,0 0 ans k=0,0 0 k L=sorted(L,key=lambda x: x[1],reverse=True) sorted(L,key=lambda x: x[1],reverse=True) L M=map(int,input().split()) map(int,input().split()) M
N,M=map(int,input().split())
A=map(int,input().split())
L=[(1,a) for a in A]
for _ in range(M):
  b,c=map(int,input().split())
  L.append((b,c))
L=sorted(L,key=lambda x: x[1],reverse=True)
ans,k=0,0
for n,a in L:
  if n+k>=N:
    ans+=a*(N-k)
    break
  else:
    ans+=a*n
    k+=n
print(ans)