import math

n, m = map(int, input().split(" "))
aL = sorted(list(map(int, input().split(" "))))
bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True)

csl = 0
for cnt, point in bcL:
    for i in range(cnt):
        if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1

print(sum(aL))
exit() import math math n, m = map(int, input().split(" ")) n map(int, input().split(" ")) map int input().split(" ") ().split () input split " " m aL = sorted(list(map(int, input().split(" ")))) aL 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 " " bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True) bcL sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True) 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 reverse=True reverse True csl = 0 csl 0 for cnt, point in bcL:
    for i in range(cnt):
        if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1 cnt point bcL for i in range(cnt):
        if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1 i range(cnt) range cnt if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
         csl == n or aL[csl] >= point csl == n csl n aL[csl] >= point aL[csl] aL csl point print(sum(aL)) print sum(aL) sum aL exit() exit aL[csl] = point aL[csl] aL csl point csl += 1 csl 1 print(sum(aL)) print sum(aL) sum aL exit() exit bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True) sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True) bcL m = map(int, input().split(" ")) map(int, input().split(" ")) m aL = sorted(list(map(int, input().split(" ")))) sorted(list(map(int, input().split(" ")))) aL n, m = map(int, input().split(" ")) map(int, input().split(" ")) n csl += 1 1 csl csl = 0 0 csl
import math

n, m = map(int, input().split(" "))
aL = sorted(list(map(int, input().split(" "))))
bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True)

csl = 0
for cnt, point in bcL:
    for i in range(cnt):
        if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1

print(sum(aL))
exit()