from heapq import heappop, heappush



n, m = list(map(int, input().split()))

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



hq = []

for aa in a:

    heappush(hq, (-aa, 1))



for _ in range(m):

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

    heappush(hq, (-c, b))



rest = n

ans = 0

while rest > 0:

    num, cnt = heappop(hq)



    num *= (-1)

    use = min(rest, cnt)

    ans += use * num

    rest -= use



print(ans)

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()

from heapq import heappop, heappush

n, m = list(map(int, input().split()))
a = tuple(map(int, input().split()))
hq = []
for aa in a:
    heappush(hq, (-aa, 1))
for _ in range(m):
    b, c = list(map(int, input().split()))
    heappush(hq, (-c, b))
rest = n
ans = 0
while rest > 0:
    num, cnt = heappop(hq)
    num *= -1
    use = min(rest, cnt)
    ans += use * num
    rest -= use
print(ans)

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()

-from heapq import heappop, heappush +def main(): +    from collections import Counter +    from operator import itemgetter +    import sys -n, m = list(map(int, input().split())) -a = tuple(map(int, input().split())) -hq = [] -for aa in a: -    heappush(hq, (-aa, 1)) -for _ in range(m): -    b, c = list(map(int, input().split())) -    heappush(hq, (-c, b)) -rest = n -ans = 0 -while rest > 0: -    num, cnt = heappop(hq) -    num *= -1 -    use = min(rest, cnt) -    ans += use * num -    rest -= use -print(ans) +    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()