n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])
bc.reverse()

flg = 0
cnt = 0

for i in range(n):
  if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
  else:
      break

print(sum(a)) 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.sort() a.sort a sort list(map(int, input().split())) for i in range(m) for i in range(m) i range(m) range m for i 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 i in range(m)], key =lambda x:x[1]) bc sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1]) sorted [list(map(int, input().split())) for i in range(m)] key =lambda x:x[1] key lambda x:x[1] x[1] x 1 x bc.reverse() bc.reverse bc reverse flg = 0 flg 0 cnt = 0 cnt 0 for i in range(n):
  if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
  else:
      break i range(n) range n if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
  else:
      break bc[flg][1] >a[i] and flg < m bc[flg][1] >a[i] bc[flg][1] [flg] bc flg 1 a[i] a i flg < m flg m a[i] = bc[flg][1] a[i] a i bc[flg][1] [flg] bc flg 1 cnt +=1 cnt 1 if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
   cnt == bc[flg][0] cnt bc[flg][0] [flg] bc flg 0 flg += 1 flg 1 cnt = 0 cnt 0 if flg == m:
        break
   flg == m flg m break break print(sum(a)) print sum(a) sum a bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1]) sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1]) bc cnt = 0 0 cnt n,m = map(int, input().split()) map(int, input().split()) n a = list(map(int, input().split())) list(map(int, input().split())) a flg = 0 0 flg cnt +=1 1 cnt cnt = 0 0 cnt flg += 1 1 flg m = map(int, input().split()) map(int, input().split()) m
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])
bc.reverse()

flg = 0
cnt = 0

for i in range(n):
  if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
  else:
      break

print(sum(a))