# coding: UTF-8

import sys

#sys.setrecursionlimit(n)

import heapq

import re

import bisect

import random

import math

import itertools

from collections import defaultdict, deque

from copy import deepcopy

from decimal import *



readl= lambda: list(map(int, sys.stdin.readline().split()))

readt= lambda: tuple(map(int, sys.stdin.readline().split()))

read = lambda: sys.stdin.readline().rstrip()

readi = lambda: int(read())

readmi = lambda: list(map(int, sys.stdin.readline().split()))

readms = lambda: list(map(str, sys.stdin.readline().split()))



n, m = readmi()

a = readl()

d = defaultdict(int)

k = []

for i in a:

    heapq.heappush(k,(-i, 1))

for i in range(m):

    x, y = readmi()

    heapq.heappush(k,(-y, x))

count = 0

while(n > 0):

    x, y = heapq.heappop(k)

    count += min(y * (-x), n * (-x))

    n = max(n - y, 0)

print(count)
# coding: UTF-8

import sys

#sys.setrecursionlimit(n)

import heapq

import re

import bisect

import random

import math

import itertools

from collections import defaultdict, deque

from copy import deepcopy

from decimal import *



readl= lambda: list(map(int, sys.stdin.readline().split()))

readt= lambda: tuple(map(int, sys.stdin.readline().split()))

read = lambda: sys.stdin.readline().rstrip()

readi = lambda: int(read())

readmi = lambda: list(map(int, sys.stdin.readline().split()))

readms = lambda: list(map(str, sys.stdin.readline().split()))



n, m = readmi()

a = readl()

d = defaultdict(int)

k = []

for i in a:

    k.append((i, 1))

for i in range(m):

    x, y = readmi()

    k.append((y, x))

count = 0

k.sort(reverse=True)

index = 0

while(n > 0):

    x, y = k[index]

    count += min(y * (x), n * (x))

    n = max(n - y, 0)

    index += 1

print(count)
# coding: UTF-8
import sys

# sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl = lambda: list(map(int, sys.stdin.readline().split()))
readt = lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: list(map(int, sys.stdin.readline().split()))
readms = lambda: list(map(str, sys.stdin.readline().split()))
n, m = readmi()
a = readl()
d = defaultdict(int)
k = []
for i in a:
    heapq.heappush(k, (-i, 1))
for i in range(m):
    x, y = readmi()
    heapq.heappush(k, (-y, x))
count = 0
while n > 0:
    x, y = heapq.heappop(k)
    count += min(y * (-x), n * (-x))
    n = max(n - y, 0)
print(count)

# coding: UTF-8
import sys

# sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl = lambda: list(map(int, sys.stdin.readline().split()))
readt = lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: list(map(int, sys.stdin.readline().split()))
readms = lambda: list(map(str, sys.stdin.readline().split()))
n, m = readmi()
a = readl()
d = defaultdict(int)
k = []
for i in a:
    k.append((i, 1))
for i in range(m):
    x, y = readmi()
    k.append((y, x))
count = 0
k.sort(reverse=True)
index = 0
while n > 0:
    x, y = k[index]
    count += min(y * (x), n * (x))
    n = max(n - y, 0)
    index += 1
print(count)

-    heapq.heappush(k, (-i, 1)) +    k.append((i, 1)) -    heapq.heappush(k, (-y, x)) +    k.append((y, x)) +k.sort(reverse=True) +index = 0 -    x, y = heapq.heappop(k) -    count += min(y * (-x), n * (-x)) +    x, y = k[index] +    count += min(y * (x), n * (x)) +    index += 1