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

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

lis = [list(map(int,input().split())) for x in range(m)]

for x in alis:

    lis.append([1,x])

lis.sort(reverse=True,key=lambda x:x[1])

ans = 0

for x in lis:

    (number,point) = x

    if number >= n:

        number = n

        ans += number * point

        #print(n)

        #print(ans,'+=',number,'*',point)

        break

    ans += number * point

    n -= number

    #print(n)

    #print(ans,'+=',number,'*',point)

print(ans)

#print(lis)

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

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

BC = []

clis = []



for x in range(m):

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

    BC.append((b,c))

BC = sorted(BC,reverse=True,key=lambda x:x[1])

bk_flg = 1

for b,c in BC:

    for x in range(b):

        if len(clis) > n:

            bk_flg = 0

            break

        clis.append(c)

    if bk_flg == 0:break;



for i in range(min(len(clis),n)):

    if alis[i] < clis[i]:

        alis[i] = clis[i]

print((sum(alis)))

n, m = list(map(int, input().split()))
alis = list(map(int, input().split()))
lis = [list(map(int, input().split())) for x in range(m)]
for x in alis:
    lis.append([1, x])
lis.sort(reverse=True, key=lambda x: x[1])
ans = 0
for x in lis:
    (number, point) = x
    if number >= n:
        number = n
        ans += number * point
        # print(n)
        # print(ans,'+=',number,'*',point)
        break
    ans += number * point
    n -= number
    # print(n)
    # print(ans,'+=',number,'*',point)
print(ans)
# print(lis)

n, m = list(map(int, input().split()))
alis = sorted(list(map(int, input().split())))
BC = []
clis = []
for x in range(m):
    b, c = list(map(int, input().split()))
    BC.append((b, c))
BC = sorted(BC, reverse=True, key=lambda x: x[1])
bk_flg = 1
for b, c in BC:
    for x in range(b):
        if len(clis) > n:
            bk_flg = 0
            break
        clis.append(c)
    if bk_flg == 0:
        break
for i in range(min(len(clis), n)):
    if alis[i] < clis[i]:
        alis[i] = clis[i]
print((sum(alis)))

-alis = list(map(int, input().split())) -lis = [list(map(int, input().split())) for x in range(m)] -for x in alis: -    lis.append([1, x]) -lis.sort(reverse=True, key=lambda x: x[1]) -ans = 0 -for x in lis: -    (number, point) = x -    if number >= n: -        number = n -        ans += number * point -        # print(n) -        # print(ans,'+=',number,'*',point) +alis = sorted(list(map(int, input().split()))) +BC = [] +clis = [] +for x in range(m): +    b, c = list(map(int, input().split())) +    BC.append((b, c)) +BC = sorted(BC, reverse=True, key=lambda x: x[1]) +bk_flg = 1 +for b, c in BC: +    for x in range(b): +        if len(clis) > n: +            bk_flg = 0 +            break +        clis.append(c) +    if bk_flg == 0: -    ans += number * point -    n -= number -    # print(n) -    # print(ans,'+=',number,'*',point) -print(ans) -# print(lis) +for i in range(min(len(clis), n)): +    if alis[i] < clis[i]: +        alis[i] = clis[i] +print((sum(alis)))