def main():

    from collections import Counter

    from operator import itemgetter



    import sys

    input = sys.stdin.readline



    N, M = list(map(int, input().split()))

    a = list(map(int, input().split()))



    ctr = Counter(a)

    for _ in range(M):

        b, c = list(map(int, input().split()))

        ctr[c] += b



    ans = 0

    rest = N

    for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):

        take = min(rest, count)

        ans += take * integer

        rest -= take

        if not rest:

            break



    print(ans)





if __name__ == '__main__':

    main()



# import sys

# input = sys.stdin.readline

# 

# sys.setrecursionlimit(10 ** 7)

# 

# (int(x)-1 for x in input().split())

# rstrip()

def main():

    from collections import defaultdict

    from operator import itemgetter

    import sys

    input = sys.stdin.readline



    N, M = list(map(int, input().split()))

    A = list(map(int, input().split()))



    ctr = defaultdict(int)

    for x in A:

        ctr[x] += 1



    for _ in range(M):

        num_of_cards, int_written_on_cards = list(map(int, input().split()))

        ctr[int_written_on_cards] += num_of_cards



    rest = N

    total = 0

    for int_written_on_cards, num_of_cards in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):

        take = min(rest, num_of_cards)



        total += int_written_on_cards * take

        rest -= take



        if rest == 0:

            break



    print(total)





if __name__ == '__main__':

    main()

def main():
    from collections import Counter
    from operator import itemgetter
    import sys

    input = sys.stdin.readline
    N, M = list(map(int, input().split()))
    a = list(map(int, input().split()))
    ctr = Counter(a)
    for _ in range(M):
        b, c = list(map(int, input().split()))
        ctr[c] += b
    ans = 0
    rest = N
    for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True):
        take = min(rest, count)
        ans += take * integer
        rest -= take
        if not rest:
            break
    print(ans)


if __name__ == "__main__":
    main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()

def main():
    from collections import defaultdict
    from operator import itemgetter
    import sys

    input = sys.stdin.readline
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    ctr = defaultdict(int)
    for x in A:
        ctr[x] += 1
    for _ in range(M):
        num_of_cards, int_written_on_cards = list(map(int, input().split()))
        ctr[int_written_on_cards] += num_of_cards
    rest = N
    total = 0
    for int_written_on_cards, num_of_cards in sorted(
        list(ctr.items()), key=itemgetter(0), reverse=True
    ):
        take = min(rest, num_of_cards)
        total += int_written_on_cards * take
        rest -= take
        if rest == 0:
            break
    print(total)


if __name__ == "__main__":
    main()

-    from collections import Counter +    from collections import defaultdict -    a = list(map(int, input().split())) -    ctr = Counter(a) +    A = list(map(int, input().split())) +    ctr = defaultdict(int) +    for x in A: +        ctr[x] += 1 -        b, c = list(map(int, input().split())) -        ctr[c] += b -    ans = 0 +        num_of_cards, int_written_on_cards = list(map(int, input().split())) +        ctr[int_written_on_cards] += num_of_cards -    for integer, count in sorted(list(ctr.items()), key=itemgetter(0), reverse=True): -        take = min(rest, count) -        ans += take * integer +    total = 0 +    for int_written_on_cards, num_of_cards in sorted( +        list(ctr.items()), key=itemgetter(0), reverse=True +    ): +        take = min(rest, num_of_cards) +        total += int_written_on_cards * take -        if not rest: +        if rest == 0: -    print(ans) +    print(total) -# import sys -# input = sys.stdin.readline -# -# sys.setrecursionlimit(10 ** 7) -# -# (int(x)-1 for x in input().split()) -# rstrip()