import bisect
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n, m = LI()
a = LI()
a = sorted(a)[::-1]
bc = LIR(m)
bc = sorted(bc, key=lambda x: x[1])[::-1]
all_c = []
for bi, ci in bc:
    all_c += [ci] * bi
    if len(all_c) >= n:
        break
if len(all_c) < n:
    all_c += [0] * (n - len(all_c))

ans = 0
a_i = 0
c_i = 0
for _ in range(n):
    if a[a_i] > all_c[c_i]:
        ans += a[a_i]
        a_i += 1
    else:
        ans += all_c[c_i]
        c_i += 1
print(ans) import bisect bisect from collections import Counter import sys sys def input(): return sys.stdin.readline().strip() input def I(): return int(input()) I def LI(): return list(map(int, input().split())) LI I() for i in range(n) for i in range(n) i range(n) range n for i in range(n) I() I def IR(n): return [I() for i in range(n)] IR n n LI() for i in range(n) for i in range(n) i range(n) range n for i in range(n) LI() LI def LIR(n): return [LI() for i in range(n)] LIR n n S() for i in range(n) for i in range(n) i range(n) range n for i in range(n) S() S def SR(n): return [S() for i in range(n)] SR n n def S(): return input() S def LS(): return input().split() LS n, m = LI() n LI() LI m a = LI() a LI() LI a = sorted(a)[::-1] a sorted(a)[::-1] (a) sorted a ::-1 -1 bc = LIR(m) bc LIR(m) LIR m bc = sorted(bc, key=lambda x: x[1])[::-1] bc sorted(bc, key=lambda x: x[1])[::-1] (bc, key=lambda x: x[1]) sorted bc key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x ::-1 -1 all_c = [] all_c [] for bi, ci in bc:
    all_c += [ci] * bi
    if len(all_c) >= n:
        break bi ci bc all_c += [ci] * bi all_c [ci] * bi [ci] ci bi if len(all_c) >= n:
        break len(all_c) >= n len(all_c) len all_c n break if len(all_c) < n:
    all_c += [0] * (n - len(all_c)) len(all_c) < n len(all_c) len all_c n all_c += [0] * (n - len(all_c)) all_c [0] * (n - len(all_c)) [0] 0 n - len(all_c) n len(all_c) len all_c ans = 0 ans 0 a_i = 0 a_i 0 c_i = 0 c_i 0 for _ in range(n):
    if a[a_i] > all_c[c_i]:
        ans += a[a_i]
        a_i += 1
    else:
        ans += all_c[c_i]
        c_i += 1 _ range(n) range n if a[a_i] > all_c[c_i]:
        ans += a[a_i]
        a_i += 1
    else:
        ans += all_c[c_i]
        c_i += 1 a[a_i] > all_c[c_i] a[a_i] a a_i all_c[c_i] all_c c_i ans += a[a_i] ans a[a_i] a a_i a_i += 1 a_i 1 ans += all_c[c_i] ans all_c[c_i] all_c c_i c_i += 1 c_i 1 print(ans) print ans n, m = LI() LI() n ans = 0 0 ans def LIR(n): return [LI() for i in range(n)] def LIR(n): return [LI() for i in range(n)] LIR c_i = 0 0 c_i def S(): return input() def S(): return input() S all_c += [0] * (n - len(all_c)) [0] * (n - len(all_c)) all_c all_c += [ci] * bi [ci] * bi all_c ans += a[a_i] a[a_i] ans def LI(): return list(map(int, input().split())) def LI(): return list(map(int, input().split())) LI bc = sorted(bc, key=lambda x: x[1])[::-1] sorted(bc, key=lambda x: x[1])[::-1] bc def I(): return int(input()) def I(): return int(input()) I a = LI() LI() a def LS(): return input().split() def LS(): return input().split() LS a = sorted(a)[::-1] sorted(a)[::-1] a a_i = 0 0 a_i m = LI() LI() m all_c = [] [] all_c def SR(n): return [S() for i in range(n)] def SR(n): return [S() for i in range(n)] SR bc = LIR(m) LIR(m) bc def input(): return sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() input def IR(n): return [I() for i in range(n)] def IR(n): return [I() for i in range(n)] IR ans += all_c[c_i] all_c[c_i] ans c_i += 1 1 c_i a_i += 1 1 a_i
import bisect
from collections import Counter
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n, m = LI()
a = LI()
a = sorted(a)[::-1]
bc = LIR(m)
bc = sorted(bc, key=lambda x: x[1])[::-1]
all_c = []
for bi, ci in bc:
    all_c += [ci] * bi
    if len(all_c) >= n:
        break
if len(all_c) < n:
    all_c += [0] * (n - len(all_c))

ans = 0
a_i = 0
c_i = 0
for _ in range(n):
    if a[a_i] > all_c[c_i]:
        ans += a[a_i]
        a_i += 1
    else:
        ans += all_c[c_i]
        c_i += 1
print(ans)
