N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
bc = [0] * M
for i in range(M):
  bc[i] = list(map(int, input().split()))
bc = sorted(bc, key = lambda x:x[1], reverse = True)


#めぐる式二分探索
#indexが条件を満たすか判定
def isOK(index, key, A):
  if A[index] < key:
    return True
  else:
    return False
  
#にぶたん
#A : 配列
def binary_search(key, A):
  N = len(A)
  ng = -1
  ok = N
  while (abs(ok - ng) > 1):
    mid = int((ok + ng) / 2)
    if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
  return ok
  
#a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910]

#print(A)
#print(binary_search(5, A))
#二分探索の結果がそれを超える枚数
fix = 0
fix2 = 0
fix3 = 0
ans = 0
for i in range(M):
  now = bc[i]
  x = binary_search(now[1], A)
  fix = x
  fix3 = now[0]
  #print(fix, fix2, fix3, ans)  
  if fix + fix2 + fix3 >= N:
    fix3 = N - fix - fix2
    ans += sum(A[:fix]) + now[1] * fix3
    print(ans)
    quit()
  else:
    fix2 += fix3
    ans += now[0] * now[1]

    
ans += sum(A[:(N - fix2)])
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 = sorted(A, reverse = True) A sorted(A, reverse = True) sorted A reverse = True reverse True bc = [0] * M bc [0] * M [0] 0 M for i in range(M):
  bc[i] = list(map(int, input().split())) i range(M) range M bc[i] = list(map(int, input().split())) bc[i] bc i list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bc = sorted(bc, key = lambda x:x[1], reverse = True) bc sorted(bc, key = lambda x:x[1], reverse = True) sorted bc key = lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse = True reverse True def isOK(index, key, A):
  if A[index] < key:
    return True
  else:
    return False
  
#にぶたん
#A : 配列 isOK if A[index] < key:
    return True
  else:
    return False
  
#にぶたん
#A : 配列 A[index] < key A[index] A index key return True True return False False index index key key A A def binary_search(key, A):
  N = len(A)
  ng = -1
  ok = N
  while (abs(ok - ng) > 1):
    mid = int((ok + ng) / 2)
    if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
  return ok
  
#a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910]

#print(A)
#print(binary_search(5, A))
#二分探索の結果がそれを超える枚数 binary_search N = len(A) N len(A) len A ng = -1 ng -1 ok = N ok N while (abs(ok - ng) > 1):
    mid = int((ok + ng) / 2)
    if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
   abs(ok - ng) > 1 abs(ok - ng) abs ok - ng ok ng 1 mid = int((ok + ng) / 2) mid int((ok + ng) / 2) int (ok + ng) / 2 ok + ng ok ng 2 if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
   isOK(mid, key, A) isOK mid key A ok = mid ok mid ng = mid ng mid return ok ok key key A A fix = 0 fix 0 fix2 = 0 fix2 0 fix3 = 0 fix3 0 ans = 0 ans 0 for i in range(M):
  now = bc[i]
  x = binary_search(now[1], A)
  fix = x
  fix3 = now[0]
  #print(fix, fix2, fix3, ans)  
  if fix + fix2 + fix3 >= N:
    fix3 = N - fix - fix2
    ans += sum(A[:fix]) + now[1] * fix3
    print(ans)
    quit()
  else:
    fix2 += fix3
    ans += now[0] * now[1]

     i range(M) range M now = bc[i] now bc[i] bc i x = binary_search(now[1], A) x binary_search(now[1], A) binary_search now[1] now 1 A fix = x fix x fix3 = now[0] fix3 now[0] now 0 if fix + fix2 + fix3 >= N:
    fix3 = N - fix - fix2
    ans += sum(A[:fix]) + now[1] * fix3
    print(ans)
    quit()
  else:
    fix2 += fix3
    ans += now[0] * now[1]

     fix + fix2 + fix3 >= N fix + fix2 + fix3 fix + fix2 fix fix2 fix3 N fix3 = N - fix - fix2 fix3 N - fix - fix2 N - fix N fix fix2 ans += sum(A[:fix]) + now[1] * fix3 ans sum(A[:fix]) + now[1] * fix3 sum(A[:fix]) sum A[:fix] A :fix fix now[1] * fix3 now[1] now 1 fix3 print(ans) print ans quit() quit fix2 += fix3 fix2 fix3 ans += now[0] * now[1] ans now[0] * now[1] now[0] now 0 now[1] now 1 ans += sum(A[:(N - fix2)]) ans sum(A[:(N - fix2)]) sum A[:(N - fix2)] A :(N - fix2) N - fix2 N fix2 print(ans) print ans N, M = map(int, input().split()) map(int, input().split()) N bc = [0] * M [0] * M bc bc = sorted(bc, key = lambda x:x[1], reverse = True) sorted(bc, key = lambda x:x[1], reverse = True) bc fix3 = 0 0 fix3 fix2 += fix3 fix3 fix2 now = bc[i] bc[i] now A = sorted(A, reverse = True) sorted(A, reverse = True) A ans += sum(A[:(N - fix2)]) sum(A[:(N - fix2)]) ans A = list(map(int, input().split())) list(map(int, input().split())) A fix3 = now[0] now[0] fix3 ans += now[0] * now[1] now[0] * now[1] ans def binary_search(key, A):
  N = len(A)
  ng = -1
  ok = N
  while (abs(ok - ng) > 1):
    mid = int((ok + ng) / 2)
    if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
  return ok
  
#a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910]

#print(A)
#print(binary_search(5, A))
#二分探索の結果がそれを超える枚数 def binary_search(key, A):
  N = len(A)
  ng = -1
  ok = N
  while (abs(ok - ng) > 1):
    mid = int((ok + ng) / 2)
    if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
  return ok
  
#a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910]

#print(A)
#print(binary_search(5, A))
#二分探索の結果がそれを超える枚数 binary_search def isOK(index, key, A):
  if A[index] < key:
    return True
  else:
    return False
  
#にぶたん
#A : 配列 def isOK(index, key, A):
  if A[index] < key:
    return True
  else:
    return False
  
#にぶたん
#A : 配列 isOK x = binary_search(now[1], A) binary_search(now[1], A) x ans += sum(A[:fix]) + now[1] * fix3 sum(A[:fix]) + now[1] * fix3 ans fix = 0 0 fix fix3 = N - fix - fix2 N - fix - fix2 fix3 M = map(int, input().split()) map(int, input().split()) M fix = x x fix ans = 0 0 ans fix2 = 0 0 fix2
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
bc = [0] * M
for i in range(M):
  bc[i] = list(map(int, input().split()))
bc = sorted(bc, key = lambda x:x[1], reverse = True)


#めぐる式二分探索
#indexが条件を満たすか判定
def isOK(index, key, A):
  if A[index] < key:
    return True
  else:
    return False
  
#にぶたん
#A : 配列
def binary_search(key, A):
  N = len(A)
  ng = -1
  ok = N
  while (abs(ok - ng) > 1):
    mid = int((ok + ng) / 2)
    if isOK(mid, key, A):
      ok = mid
    else:
      ng = mid
  return ok
  
#a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910]

#print(A)
#print(binary_search(5, A))
#二分探索の結果がそれを超える枚数
fix = 0
fix2 = 0
fix3 = 0
ans = 0
for i in range(M):
  now = bc[i]
  x = binary_search(now[1], A)
  fix = x
  fix3 = now[0]
  #print(fix, fix2, fix3, ans)  
  if fix + fix2 + fix3 >= N:
    fix3 = N - fix - fix2
    ans += sum(A[:fix]) + now[1] * fix3
    print(ans)
    quit()
  else:
    fix2 += fix3
    ans += now[0] * now[1]

    
ans += sum(A[:(N - fix2)])
print(ans)
  
  
  

