

import heapq



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

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

BC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True)



if N == 1:

    print((max(A[0], BC[0][1])))

    quit()



heapq.heapify(A)

for b, c in BC:

    a = A[0]

    if a >= c:

        continue

    else:

        curPopped = 0

        while curPopped < b:

            a = heapq.heappop(A)

            if a >= c:

                heapq.heappush(A, a)

                break

            curPopped += 1

        for i in range(curPopped):

            heapq.heappush(A, c)



print((sum(A)))

"""

import bisect

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

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

BC = [list(map(int, input().split())) for i in range(M)]



if N == 1:

    print(max(A[0], BC[0][1]))

    quit()



for b, c in BC:

    a = A[0]

    if a >= c:

        continue

    else:

        l = bisect.bisect_left(A, c)

        print(l)

        l = min(b, l)

        A = A[l:] + [c] * l

        print(l, A)



print(sum(A))

"""
import heapq



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

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

BC = sorted([list(map(int, input().split())) for i in range(M)], key=lambda x: x[1], reverse=True)



if N == 1:

    print((max(A[0], BC[0][1])))

    quit()



heapq.heapify(A)

for b, c in BC:

    a = A[0]

    if a >= c:

        continue

    else:

        curPopped = 0

        while curPopped < b:

            a = heapq.heappop(A)

            if a >= c:

                heapq.heappush(A, a)

                break

            curPopped += 1

        for i in range(curPopped):

            heapq.heappush(A, c)



print((sum(A)))

import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = sorted(
    [list(map(int, input().split())) for i in range(M)],
    key=lambda x: x[1],
    reverse=True,
)
if N == 1:
    print((max(A[0], BC[0][1])))
    quit()
heapq.heapify(A)
for b, c in BC:
    a = A[0]
    if a >= c:
        continue
    else:
        curPopped = 0
        while curPopped < b:
            a = heapq.heappop(A)
            if a >= c:
                heapq.heappush(A, a)
                break
            curPopped += 1
        for i in range(curPopped):
            heapq.heappush(A, c)
print((sum(A)))
"""
import bisect
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for i in range(M)]
if N == 1:
    print(max(A[0], BC[0][1]))
    quit()
for b, c in BC:
    a = A[0]
    if a >= c:
        continue
    else:
        l = bisect.bisect_left(A, c)
        print(l)
        l = min(b, l)
        A = A[l:] + [c] * l
        print(l, A)
print(sum(A))
"""

import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = sorted(
    [list(map(int, input().split())) for i in range(M)],
    key=lambda x: x[1],
    reverse=True,
)
if N == 1:
    print((max(A[0], BC[0][1])))
    quit()
heapq.heapify(A)
for b, c in BC:
    a = A[0]
    if a >= c:
        continue
    else:
        curPopped = 0
        while curPopped < b:
            a = heapq.heappop(A)
            if a >= c:
                heapq.heappush(A, a)
                break
            curPopped += 1
        for i in range(curPopped):
            heapq.heappush(A, c)
print((sum(A)))

-""" -import bisect -N, M = map(int, input().split()) -A = sorted(list(map(int, input().split()))) -BC = [list(map(int, input().split())) for i in range(M)] -if N == 1: -    print(max(A[0], BC[0][1])) -    quit() -for b, c in BC: -    a = A[0] -    if a >= c: -        continue -    else: -        l = bisect.bisect_left(A, c) -        print(l) -        l = min(b, l) -        A = A[l:] + [c] * l -        print(l, A) -print(sum(A)) -"""