
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
from heapq import heapify,heappush,heappop
n,m=n1()
A=n1()
BC=t3(m)

heapify(A)
BC.sort(key=lambda x:-x[1])

D=[]
for b,c in BC:
    D.extend([c]*b)
    if len(D)>=n:
        break
D=D[:n]


for d in D:
    a=heappop(A)
    if a>=d:
        heappush(A,a)
        break;
    else:
        heappush(A,d)

print(sum(A)) def s0():return input() s0 def s1():return input().split() s1 input() for x in range(n) for x in range(n) x range(n) range n for x in range(n) input() input def s2(n):return [input() for x in range(n)] s2 n n input().split() for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) input().split() ().split () input split def s3(n):return [input().split() for _ in range(n)] s3 n n [x for x in s] for s in s2(n) for s in s2(n) s s2(n) s2 n for s in s2(n) [x for x in s] def s4(n):return [[x for x in s] for s in s2(n)] s4 n n def n0():return int(input()) n0 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x def n1():return [int(x) for x in input().split()] n1 int(input()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) int(input()) int input() input def n2(n):return [int(input()) for _ in range(n)] n2 n n [int(x) for x in input().split()] for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [int(x) for x in input().split()] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] n3 n n tuple(int(x) for x in input().split()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) tuple(int(x) for x in input().split()) tuple int(x) int x def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)] t3 n n def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right p0 b b yes="Yes" yes "Yes" no="No" no "No" from heapq import heapify,heappush,heappop n,m=n1() n n1() n1 m A=n1() A n1() n1 BC=t3(m) BC t3(m) t3 m heapify(A) heapify A BC.sort(key=lambda x:-x[1]) BC.sort BC sort key=lambda x:-x[1] key lambda x:-x[1] -x[1] x[1] x 1 x D=[] D [] for b,c in BC:
    D.extend([c]*b)
    if len(D)>=n:
        break b c BC D.extend([c]*b) D.extend D extend [c]*b [c] c b if len(D)>=n:
        break len(D)>=n len(D) len D n break D=D[:n] D D[:n] D :n n for d in D:
    a=heappop(A)
    if a>=d:
        heappush(A,a)
        break;
    else:
        heappush(A,d) d D a=heappop(A) a heappop(A) heappop A if a>=d:
        heappush(A,a)
        break;
    else:
        heappush(A,d) a>=d a d heappush(A,a) heappush A a break heappush(A,d) heappush A d print(sum(A)) print sum(A) sum A def n1():return [int(x) for x in input().split()] def n1():return [int(x) for x in input().split()] n1 def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right p0 def s3(n):return [input().split() for _ in range(n)] def s3(n):return [input().split() for _ in range(n)] s3 def s0():return input() def s0():return input() s0 def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] n3 a=heappop(A) heappop(A) a m=n1() n1() m D=D[:n] D[:n] D def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)] def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)] t3 n,m=n1() n1() n BC=t3(m) t3(m) BC def s1():return input().split() def s1():return input().split() s1 D=[] [] D def n0():return int(input()) def n0():return int(input()) n0 def s4(n):return [[x for x in s] for s in s2(n)] def s4(n):return [[x for x in s] for s in s2(n)] s4 def s2(n):return [input() for x in range(n)] def s2(n):return [input() for x in range(n)] s2 A=n1() n1() A def n2(n):return [int(input()) for _ in range(n)] def n2(n):return [int(input()) for _ in range(n)] n2

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
from heapq import heapify,heappush,heappop
n,m=n1()
A=n1()
BC=t3(m)

heapify(A)
BC.sort(key=lambda x:-x[1])

D=[]
for b,c in BC:
    D.extend([c]*b)
    if len(D)>=n:
        break
D=D[:n]


for d in D:
    a=heappop(A)
    if a>=d:
        heappush(A,a)
        break;
    else:
        heappush(A,d)

print(sum(A))