#python3

from heapq import heappop, heappush



def main():

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

    hq = [] 

    for i in input().split():

        heappush(hq, (-int(i), 1))

    for _ in range(m):

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

        heappush(hq, (-c, b))

    ans = 0

    for i in range(n):

        v, u = heappop(hq)

        u = u - 1

        if u >= 1:

            heappush(hq, (v, u))

        v = - v 

        ans = ans + v

    print(ans)

main()

#python3

def main():

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

    cards = [(int(i), 1) for i in input().split()]

    for _ in range(m):

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

        cards.append((c, b))

    cards.sort(reverse=True)

    ans = 0

    sumv = 0

    for i in range(n):

        v = cards[i][1]

        cv = cards[i][0] * v

        ans += cv

        sumv += v

        if sumv >= n:

            ans -= cards[i][0] * (sumv - n)

            break

    print(ans)

main()
# python3
from heapq import heappop, heappush


def main():
    n, m = list(map(int, input().split()))
    hq = []
    for i in input().split():
        heappush(hq, (-int(i), 1))
    for _ in range(m):
        b, c = list(map(int, input().split()))
        heappush(hq, (-c, b))
    ans = 0
    for i in range(n):
        v, u = heappop(hq)
        u = u - 1
        if u >= 1:
            heappush(hq, (v, u))
        v = -v
        ans = ans + v
    print(ans)


main()

# python3
def main():
    n, m = list(map(int, input().split()))
    cards = [(int(i), 1) for i in input().split()]
    for _ in range(m):
        b, c = list(map(int, input().split()))
        cards.append((c, b))
    cards.sort(reverse=True)
    ans = 0
    sumv = 0
    for i in range(n):
        v = cards[i][1]
        cv = cards[i][0] * v
        ans += cv
        sumv += v
        if sumv >= n:
            ans -= cards[i][0] * (sumv - n)
            break
    print(ans)


main()

-from heapq import heappop, heappush - - -    hq = [] -    for i in input().split(): -        heappush(hq, (-int(i), 1)) +    cards = [(int(i), 1) for i in input().split()] -        heappush(hq, (-c, b)) +        cards.append((c, b)) +    cards.sort(reverse=True) +    sumv = 0 -        v, u = heappop(hq) -        u = u - 1 -        if u >= 1: -            heappush(hq, (v, u)) -        v = -v -        ans = ans + v +        v = cards[i][1] +        cv = cards[i][0] * v +        ans += cv +        sumv += v +        if sumv >= n: +            ans -= cards[i][0] * (sumv - n) +            break