n,m = map(int, input().split())
List = list(map(int, input().split()))
List.sort()
cand = []
for _ in range(m):
  b,c = map(int,input().split())
  cand.append((b,c))
bc = sorted(cand, key=lambda x: x[1], reverse=True)
i = 0
for b, c in bc:
    while b:
        if i < n and List[i] < c:
            List[i] = c
            b -= 1
        else:
            break
        i += 1
print(sum(List)) n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m List = list(map(int, input().split())) List list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split List.sort() List.sort List sort cand = [] cand [] for _ in range(m):
  b,c = map(int,input().split())
  cand.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 cand.append((b,c)) cand.append cand append (b,c) b c bc = sorted(cand, key=lambda x: x[1], reverse=True) bc sorted(cand, key=lambda x: x[1], reverse=True) sorted cand key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True i = 0 i 0 for b, c in bc:
    while b:
        if i < n and List[i] < c:
            List[i] = c
            b -= 1
        else:
            break
        i += 1 b c bc while b:
        if i < n and List[i] < c:
            List[i] = c
            b -= 1
        else:
            break
        i += 1 b if i < n and List[i] < c:
            List[i] = c
            b -= 1
        else:
            break
         i < n and List[i] < c i < n i n List[i] < c List[i] List i c List[i] = c List[i] List i c b -= 1 b 1 break i += 1 i 1 print(sum(List)) print sum(List) sum List b -= 1 1 b n,m = map(int, input().split()) map(int, input().split()) n cand = [] [] cand bc = sorted(cand, key=lambda x: x[1], reverse=True) sorted(cand, key=lambda x: x[1], reverse=True) bc i = 0 0 i List = list(map(int, input().split())) list(map(int, input().split())) List b,c = map(int,input().split()) map(int,input().split()) b m = map(int, input().split()) map(int, input().split()) m c = map(int,input().split()) map(int,input().split()) c i += 1 1 i
n,m = map(int, input().split())
List = list(map(int, input().split()))
List.sort()
cand = []
for _ in range(m):
  b,c = map(int,input().split())
  cand.append((b,c))
bc = sorted(cand, key=lambda x: x[1], reverse=True)
i = 0
for b, c in bc:
    while b:
        if i < n and List[i] < c:
            List[i] = c
            b -= 1
        else:
            break
        i += 1
print(sum(List))