import sys
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n, m = inm()
a = inl()


def solve():
    g = []
    for i in range(m):
        b, c = inm()
        g.append((c, b))
    g.sort(reverse=True)
    h = []
    for c, b in g:
        if len(h) == n:
            break
        for i in range(b):
            h.append(c)
            if len(h) == n:
                break
    assert len(h) <= n

    heapq.heapify(a)
    for x in h:
        if a[0] >= x:
            break
        heapq.heappush(a, x)
        heapq.heappop(a)
    return sum(a)


print(solve()) import sys sys import heapq heapq sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 ini = lambda: int(sys.stdin.readline()) ini lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline inm = lambda: map(int, sys.stdin.readline().split()) inm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inl = lambda: list(inm()) inl lambda: list(inm()) list(inm()) list inm() inm ins = lambda: sys.stdin.readline().rstrip() ins 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 debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) debug lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) print "\033[33m" *a a "\033[0m" **dict(file=sys.stderr, **kw) dict(file=sys.stderr, **kw) dict file=sys.stderr file sys.stderr sys stderr **kw kw *a **kw n, m = inm() n inm() inm m a = inl() a inl() inl def solve():
    g = []
    for i in range(m):
        b, c = inm()
        g.append((c, b))
    g.sort(reverse=True)
    h = []
    for c, b in g:
        if len(h) == n:
            break
        for i in range(b):
            h.append(c)
            if len(h) == n:
                break
    assert len(h) <= n

    heapq.heapify(a)
    for x in h:
        if a[0] >= x:
            break
        heapq.heappush(a, x)
        heapq.heappop(a)
    return sum(a) solve g = [] g [] for i in range(m):
        b, c = inm()
        g.append((c, b))
     i range(m) range m b, c = inm() b inm() inm c g.append((c, b)) g.append g append (c, b) c b g.sort(reverse=True) g.sort g sort reverse=True reverse True h = [] h [] for c, b in g:
        if len(h) == n:
            break
        for i in range(b):
            h.append(c)
            if len(h) == n:
                break
     c b g if len(h) == n:
            break
         len(h) == n len(h) len h n break for i in range(b):
            h.append(c)
            if len(h) == n:
                break
     i range(b) range b h.append(c) h.append h append c if len(h) == n:
                break
     len(h) == n len(h) len h n break assert len(h) <= n len(h) <= n len(h) len h n heapq.heapify(a) heapq.heapify heapq heapify a for x in h:
        if a[0] >= x:
            break
        heapq.heappush(a, x)
        heapq.heappop(a)
     x h if a[0] >= x:
            break
         a[0] >= x a[0] a 0 x break heapq.heappush(a, x) heapq.heappush heapq heappush a x heapq.heappop(a) heapq.heappop heapq heappop a return sum(a) sum(a) sum a print(solve()) print solve() solve n, m = inm() inm() n def solve():
    g = []
    for i in range(m):
        b, c = inm()
        g.append((c, b))
    g.sort(reverse=True)
    h = []
    for c, b in g:
        if len(h) == n:
            break
        for i in range(b):
            h.append(c)
            if len(h) == n:
                break
    assert len(h) <= n

    heapq.heapify(a)
    for x in h:
        if a[0] >= x:
            break
        heapq.heappush(a, x)
        heapq.heappop(a)
    return sum(a) def solve():
    g = []
    for i in range(m):
        b, c = inm()
        g.append((c, b))
    g.sort(reverse=True)
    h = []
    for c, b in g:
        if len(h) == n:
            break
        for i in range(b):
            h.append(c)
            if len(h) == n:
                break
    assert len(h) <= n

    heapq.heapify(a)
    for x in h:
        if a[0] >= x:
            break
        heapq.heappush(a, x)
        heapq.heappop(a)
    return sum(a) solve inm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) inm ins = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() ins inl = lambda: list(inm()) lambda: list(inm()) inl debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) debug ini = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ini m = inm() inm() m a = inl() inl() a
import sys
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n, m = inm()
a = inl()


def solve():
    g = []
    for i in range(m):
        b, c = inm()
        g.append((c, b))
    g.sort(reverse=True)
    h = []
    for c, b in g:
        if len(h) == n:
            break
        for i in range(b):
            h.append(c)
            if len(h) == n:
                break
    assert len(h) <= n

    heapq.heapify(a)
    for x in h:
        if a[0] >= x:
            break
        heapq.heappush(a, x)
        heapq.heappop(a)
    return sum(a)


print(solve())
