def main():

    N, M = (int(i) for i in input().split())

    A = [int(i) for i in input().split()]

    bcs = [[int(i) for i in input().split()] for _ in range(M)]

    A.sort()

    bcs.sort(reverse=True,key=lambda c:c[1])



    cards = []

    for b,c in bcs:

        for i in range(b):

            cards.append(c)

            if len(cards) == N:

                break

        if len(cards) == N:

            break



    from itertools import zip_longest

    ans = 0

    for a,card in zip_longest(A,cards,fillvalue=0):

        if a < card:

            ans += card

        else:

            ans += a

    print(ans)



if __name__ == "__main__":

    main()

def main():

    import sys

    input = sys.stdin.buffer.readline

    # from heapq import heappop, heappush

    N, M = (int(i) for i in input().split())

    A = [int(i) for i in input().split()]

    A.sort(reverse=True)

    BC = [[int(i) for i in input().split()] for j in range(M)]

    BC.sort(key=lambda p: p[1], reverse=True)

    p = 0

    flag = False

    for b, c in BC:

        for i in range(b):

            if A and A[-1] < c:

                A.pop()

                p += c

            else:

                flag = True

                break

        if flag:

            break

    print((sum(A) + p))





if __name__ == '__main__':

    main()

def main():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    bcs = [[int(i) for i in input().split()] for _ in range(M)]
    A.sort()
    bcs.sort(reverse=True, key=lambda c: c[1])
    cards = []
    for b, c in bcs:
        for i in range(b):
            cards.append(c)
            if len(cards) == N:
                break
        if len(cards) == N:
            break
    from itertools import zip_longest

    ans = 0
    for a, card in zip_longest(A, cards, fillvalue=0):
        if a < card:
            ans += card
        else:
            ans += a
    print(ans)


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.buffer.readline
    # from heapq import heappop, heappush
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort(reverse=True)
    BC = [[int(i) for i in input().split()] for j in range(M)]
    BC.sort(key=lambda p: p[1], reverse=True)
    p = 0
    flag = False
    for b, c in BC:
        for i in range(b):
            if A and A[-1] < c:
                A.pop()
                p += c
            else:
                flag = True
                break
        if flag:
            break
    print((sum(A) + p))


if __name__ == "__main__":
    main()

+    import sys + +    input = sys.stdin.buffer.readline +    # from heapq import heappop, heappush -    bcs = [[int(i) for i in input().split()] for _ in range(M)] -    A.sort() -    bcs.sort(reverse=True, key=lambda c: c[1]) -    cards = [] -    for b, c in bcs: +    A.sort(reverse=True) +    BC = [[int(i) for i in input().split()] for j in range(M)] +    BC.sort(key=lambda p: p[1], reverse=True) +    p = 0 +    flag = False +    for b, c in BC: -            cards.append(c) -            if len(cards) == N: +            if A and A[-1] < c: +                A.pop() +                p += c +            else: +                flag = True -        if len(cards) == N: +        if flag: -    from itertools import zip_longest - -    ans = 0 -    for a, card in zip_longest(A, cards, fillvalue=0): -        if a < card: -            ans += card -        else: -            ans += a -    print(ans) +    print((sum(A) + p))