# input
n, m = map(int, input().split())
data = [[int(i), 1] for i in input().split()]
for i in range(m):
  b, c = map(int, input().split())
  data.append([c, b])
data.sort(key=lambda x:x[0], reverse=True)

# main
ans = 0
cnt = n
for i in range(len(data)):
  if cnt >= data[i][1]:
    ans += data[i][0] * data[i][1]
    cnt -= data[i][1]
  else:
    ans += data[i][0] * cnt
    cnt -= data[i][1]
  if cnt <= 0:
    break
    
# output
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m [int(i), 1] for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() [int(i), 1] int(i) int i 1 data = [[int(i), 1] for i in input().split()] data [[int(i), 1] for i in input().split()] for i in range(m):
  b, c = map(int, input().split())
  data.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 data.append([c, b]) data.append data append [c, b] c b data.sort(key=lambda x:x[0], reverse=True) data.sort data sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x reverse=True reverse True ans = 0 ans 0 cnt = n cnt n for i in range(len(data)):
  if cnt >= data[i][1]:
    ans += data[i][0] * data[i][1]
    cnt -= data[i][1]
  else:
    ans += data[i][0] * cnt
    cnt -= data[i][1]
  if cnt <= 0:
    break
    
# output i range(len(data)) range len(data) len data if cnt >= data[i][1]:
    ans += data[i][0] * data[i][1]
    cnt -= data[i][1]
  else:
    ans += data[i][0] * cnt
    cnt -= data[i][1]
   cnt >= data[i][1] cnt data[i][1] [i] data i 1 ans += data[i][0] * data[i][1] ans data[i][0] * data[i][1] data[i][0] [i] data i 0 data[i][1] [i] data i 1 cnt -= data[i][1] cnt data[i][1] [i] data i 1 ans += data[i][0] * cnt ans data[i][0] * cnt data[i][0] [i] data i 0 cnt cnt -= data[i][1] cnt data[i][1] [i] data i 1 if cnt <= 0:
    break
    
# output cnt <= 0 cnt 0 break print(ans) print ans ans = 0 0 ans n, m = map(int, input().split()) map(int, input().split()) n ans += data[i][0] * cnt data[i][0] * cnt ans cnt -= data[i][1] data[i][1] cnt cnt -= data[i][1] data[i][1] cnt c = map(int, input().split()) map(int, input().split()) c m = map(int, input().split()) map(int, input().split()) m cnt = n n cnt data = [[int(i), 1] for i in input().split()] [[int(i), 1] for i in input().split()] data b, c = map(int, input().split()) map(int, input().split()) b ans += data[i][0] * data[i][1] data[i][0] * data[i][1] ans
# input
n, m = map(int, input().split())
data = [[int(i), 1] for i in input().split()]
for i in range(m):
  b, c = map(int, input().split())
  data.append([c, b])
data.sort(key=lambda x:x[0], reverse=True)

# main
ans = 0
cnt = n
for i in range(len(data)):
  if cnt >= data[i][1]:
    ans += data[i][0] * data[i][1]
    cnt -= data[i][1]
  else:
    ans += data[i][0] * cnt
    cnt -= data[i][1]
  if cnt <= 0:
    break
    
# output
print(ans)