import sys
input = lambda : sys.stdin.readline().rstrip()

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    bc.append(list(map(int, input().split())))
bc = sorted(bc, reverse=True, key=lambda x: x[1])
cnt = n
for b, c in bc:
    if cnt <= b:
        for i in range(cnt):
            a.append(c)
        break
    else:
        for i in range(b):
            a.append(c)
        cnt -= b
a = sorted(a, reverse=True)
print(sum(a[:n]))
 import sys sys input = lambda : sys.stdin.readline().rstrip() input lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip 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 bc = [] bc [] for _ in range(m):
    bc.append(list(map(int, input().split()))) _ range(m) range m bc.append(list(map(int, input().split()))) bc.append bc append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bc = sorted(bc, reverse=True, key=lambda x: x[1]) bc sorted(bc, reverse=True, key=lambda x: x[1]) sorted bc reverse=True reverse True key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x cnt = n cnt n for b, c in bc:
    if cnt <= b:
        for i in range(cnt):
            a.append(c)
        break
    else:
        for i in range(b):
            a.append(c)
        cnt -= b b c bc if cnt <= b:
        for i in range(cnt):
            a.append(c)
        break
    else:
        for i in range(b):
            a.append(c)
        cnt -= b cnt <= b cnt b for i in range(cnt):
            a.append(c)
         i range(cnt) range cnt a.append(c) a.append a append c break for i in range(b):
            a.append(c)
         i range(b) range b a.append(c) a.append a append c cnt -= b cnt b a = sorted(a, reverse=True) a sorted(a, reverse=True) sorted a reverse=True reverse True print(sum(a[:n])) print sum(a[:n]) sum a[:n] a :n n a = list(map(int, input().split())) list(map(int, input().split())) a m = map(int, input().split()) map(int, input().split()) m bc = sorted(bc, reverse=True, key=lambda x: x[1]) sorted(bc, reverse=True, key=lambda x: x[1]) bc cnt = n n cnt cnt -= b b cnt bc = [] [] bc n, m = map(int, input().split()) map(int, input().split()) n input = lambda : sys.stdin.readline().rstrip() lambda : sys.stdin.readline().rstrip() input a = sorted(a, reverse=True) sorted(a, reverse=True) a
import sys
input = lambda : sys.stdin.readline().rstrip()

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = []
for _ in range(m):
    bc.append(list(map(int, input().split())))
bc = sorted(bc, reverse=True, key=lambda x: x[1])
cnt = n
for b, c in bc:
    if cnt <= b:
        for i in range(cnt):
            a.append(c)
        break
    else:
        for i in range(b):
            a.append(c)
        cnt -= b
a = sorted(a, reverse=True)
print(sum(a[:n]))

