n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
bc = sorted([list(map(int,input().split())) for _ in range(m)],key = lambda x:-x[1])
flag = 0
flag_2 = 0
#print(a,bc)
for i in range(n):
  if a[i] < bc[flag_2][1]:
    a[i] = bc[flag_2][1]
  else:
    break
  flag += 1
  if flag == bc[flag_2][0]:
    flag_2 += 1
    flag = 0
  if flag_2 == m:
    break
print(sum(a)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a = sorted(list(map(int,input().split()))) a sorted(list(map(int,input().split()))) sorted list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split bc = sorted([list(map(int,input().split())) for _ in range(m)],key = lambda x:-x[1]) bc sorted([list(map(int,input().split())) for _ in range(m)],key = lambda x:-x[1]) sorted [list(map(int,input().split())) for _ in range(m)] key = lambda x:-x[1] key lambda x:-x[1] -x[1] x[1] x 1 x flag = 0 flag 0 flag_2 = 0 flag_2 0 for i in range(n):
  if a[i] < bc[flag_2][1]:
    a[i] = bc[flag_2][1]
  else:
    break
  flag += 1
  if flag == bc[flag_2][0]:
    flag_2 += 1
    flag = 0
  if flag_2 == m:
    break i range(n) range n if a[i] < bc[flag_2][1]:
    a[i] = bc[flag_2][1]
  else:
    break
   a[i] < bc[flag_2][1] a[i] a i bc[flag_2][1] [flag_2] bc flag_2 1 a[i] = bc[flag_2][1] a[i] a i bc[flag_2][1] [flag_2] bc flag_2 1 break flag += 1 flag 1 if flag == bc[flag_2][0]:
    flag_2 += 1
    flag = 0
   flag == bc[flag_2][0] flag bc[flag_2][0] [flag_2] bc flag_2 0 flag_2 += 1 flag_2 1 flag = 0 flag 0 if flag_2 == m:
    break flag_2 == m flag_2 m break print(sum(a)) print sum(a) sum a m = map(int,input().split()) map(int,input().split()) m bc = sorted([list(map(int,input().split())) for _ in range(m)],key = lambda x:-x[1]) sorted([list(map(int,input().split())) for _ in range(m)],key = lambda x:-x[1]) bc flag += 1 1 flag flag = 0 0 flag n,m = map(int,input().split()) map(int,input().split()) n a = sorted(list(map(int,input().split()))) sorted(list(map(int,input().split()))) a flag = 0 0 flag flag_2 += 1 1 flag_2 flag_2 = 0 0 flag_2
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
bc = sorted([list(map(int,input().split())) for _ in range(m)],key = lambda x:-x[1])
flag = 0
flag_2 = 0
#print(a,bc)
for i in range(n):
  if a[i] < bc[flag_2][1]:
    a[i] = bc[flag_2][1]
  else:
    break
  flag += 1
  if flag == bc[flag_2][0]:
    flag_2 += 1
    flag = 0
  if flag_2 == m:
    break
print(sum(a))