import sys

input = lambda: sys.stdin.readline()[:-1]

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

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

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

for i in a0:

	data.append([1,i])

data.sort(key=lambda tup:-tup[1])

ans=0

for num,val in data:

	if n>=num:

		n-=num

		ans+=val*num

	else:

		ans+=val*n

		break

print(ans)

#!/usr/bin/env python3

import sys

from collections import Counter

input = lambda: sys.stdin.readline()[:-1]

sys.setrecursionlimit(10**8)



ans=0

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

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

bc=[]

for i in range(m):

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

    bc.append((c,b))

C=Counter(A)

bc+=list(C.items())

bc.sort(key=lambda tup:-tup[0])

# print(bc)

for c,b in bc:

    if n>=b:

        n-=b

        ans+=c*b

    else:

        ans+=c*n

        break

print(ans)



import sys

input = lambda: sys.stdin.readline()[:-1]
n, m = list(map(int, input().split()))
a0 = list(map(int, input().split()))
data = [list(map(int, input().split())) for i in range(m)]
for i in a0:
    data.append([1, i])
data.sort(key=lambda tup: -tup[1])
ans = 0
for num, val in data:
    if n >= num:
        n -= num
        ans += val * num
    else:
        ans += val * n
        break
print(ans)

#!/usr/bin/env python3
import sys
from collections import Counter

input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
ans = 0
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
bc = []
for i in range(m):
    b, c = list(map(int, input().split()))
    bc.append((c, b))
C = Counter(A)
bc += list(C.items())
bc.sort(key=lambda tup: -tup[0])
# print(bc)
for c, b in bc:
    if n >= b:
        n -= b
        ans += c * b
    else:
        ans += c * n
        break
print(ans)

+#!/usr/bin/env python3 +from collections import Counter +sys.setrecursionlimit(10**8) +ans = 0 -a0 = list(map(int, input().split())) -data = [list(map(int, input().split())) for i in range(m)] -for i in a0: -    data.append([1, i]) -data.sort(key=lambda tup: -tup[1]) -ans = 0 -for num, val in data: -    if n >= num: -        n -= num -        ans += val * num +A = list(map(int, input().split())) +bc = [] +for i in range(m): +    b, c = list(map(int, input().split())) +    bc.append((c, b)) +C = Counter(A) +bc += list(C.items()) +bc.sort(key=lambda tup: -tup[0]) +# print(bc) +for c, b in bc: +    if n >= b: +        n -= b +        ans += c * b -        ans += val * n +        ans += c * n