### BUGGY CODE ###

def Technique_often_used():    
    # enumerate: for i, a in enumerate(a_list):
    # q, mod = divmod(a, b)
    # Functional Programming: filter, map, reduce
    pass
def naming_conventions():
    # [s_1, s_2, s_3, ..., s_k] is named s_k
    # [[s_11, s_12, ..., s_1k], ..,[s_j1, s_j2, ..., s_jk] is named s_jk
    # [[b1,c1],[b2,c2],..,[bm,cm]] is named bc
    # if there is something strange in a list then I add _ to the list's name (ex:s_jk_)
    pass
def visual_studio_code_shortcut():    
    # visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
    # delete line: Ctrl+Shift+k
    # choose same words: Ctrl+Shift+l
    pass
import sys
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers): #
    return reduce(lcm, numbers, 1)
    
# toggle test environment
is_test = False
def debug_print(value,comments="",is_test=is_test):
    # print() for test environment
    # debug_print([]) => []
    # debug_print("") => 
    # debug_print(a, "a is") => "a is:" print(a)
    if not is_test:
        pass
    elif not comments and value is None:
        print("")
    elif not comments:
        print(value)
    else:
        print(comments,":",value)

# set the inputs
if is_test:
    n,m = [10, 3]
    lr = [[3,6],[5,7],[6,9]]
else:
    # open(0).read() is a convenient method: 
    # ex) n, m, *x = map(int, open(0).read().split())
    #     min(x[::2]) - max(x[1::2])
    # ex2) *x, = map(int, open(0).read().split())
    #     don't forget to add comma after *x if only one variable is used
    R = lambda: map(int, input().split())
    # ex1) n, k = R()
    # ex2) v = list(R())
    # ex3) bc = [list(R()) for i in range(m)]
    n,m = R()
    a = list(R())
    bc = [list(R()) for i in range(m)]

    # s = sys.stdin.readlines()
    # n, m = map(int, s[0].split())
    # a = list(map(int,s[1].split()))

# heapify(a)
for i in bc:
    b,c = i
    a.extend([c for i in range(b)])
    # count = 0
    # while count < b:
    #     if a[0] > c:
    #         break
    #     count += 1
    #     heappushpop(a,c)
print(sum(sorted(a)[-n:]))


### FIXED CODE ###

def Technique_often_used():    
    # enumerate: for i, a in enumerate(a_list):
    # q, mod = divmod(a, b)
    # Functional Programming: filter, map, reduce
    pass
def naming_conventions():
    # [s_1, s_2, s_3, ..., s_k] is named s_k
    # [[s_11, s_12, ..., s_1k], ..,[s_j1, s_j2, ..., s_jk] is named s_jk
    # [[b1,c1],[b2,c2],..,[bm,cm]] is named bc
    # if there is something strange in a list then I add _ to the list's name (ex:s_jk_)
    pass
def visual_studio_code_shortcut():    
    # visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
    # delete line: Ctrl+Shift+k
    # choose same words: Ctrl+Shift+l
    pass
import sys
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers): #
    return reduce(lcm, numbers, 1)
    
# toggle test environment
is_test = False
def debug_print(value,comments="",is_test=is_test):
    # print() for test environment
    # debug_print([]) => []
    # debug_print("") => 
    # debug_print(a, "a is") => "a is:" print(a)
    if not is_test:
        pass
    elif not comments and value is None:
        print("")
    elif not comments:
        print(value)
    else:
        print(comments,":",value)

# set the inputs
if is_test:
    n,m = [3, 2]
    a = [5, 1, 4]
    bc = [[2,3],[1,5]]
else:
    # open(0).read() is a convenient method: 
    # ex) n, m, *x = map(int, open(0).read().split())
    #     min(x[::2]) - max(x[1::2])
    # ex2) *x, = map(int, open(0).read().split())
    #     don't forget to add comma after *x if only one variable is used
    R = lambda: map(int, input().split())
    # ex1) n, k = R()
    # ex2) v = list(R())
    # ex3) bc = [list(R()) for i in range(m)]
    n,m = R()
    a = list(R())
    bc = [list(R()) for i in range(m)]

a = sorted(a,reverse=True)
bc = sorted(bc, key=lambda x:x[1],reverse=True)
count = 0
cs = []
for b,c in bc:
    cs.extend([c]*b)
    count += b
    if count >= n:
        break
a.extend(cs)
print(sum(sorted(a,reverse=True)[:n:]))