from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
a = LIST()
b = [LIST() for i in range(m)]
b.sort(key=itemgetter(1), reverse=True)

c = []
for i in range(m):
    c += [b[i][1]]*b[i][0]
    if len(c) > n:
        break

a += c
a.sort(reverse=True)
print(sum(a[:n])) from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heappop,heappush from copy import deepcopy from time import time import string string import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 def input() : return sys.stdin.readline().strip() input def INT()   : return int(input()) INT def MAP()   : return map(int,input().split()) MAP def LIST()  : return list(MAP()) LIST n, m = MAP() n MAP() MAP m a = LIST() a LIST() LIST LIST() for i in range(m) for i in range(m) i range(m) range m for i in range(m) LIST() LIST b = [LIST() for i in range(m)] b [LIST() for i in range(m)] b.sort(key=itemgetter(1), reverse=True) b.sort b sort key=itemgetter(1) key itemgetter(1) itemgetter 1 reverse=True reverse True c = [] c [] for i in range(m):
    c += [b[i][1]]*b[i][0]
    if len(c) > n:
        break i range(m) range m c += [b[i][1]]*b[i][0] c [b[i][1]]*b[i][0] [b[i][1]] b[i][1] [i] b i 1 b[i][0] [i] b i 0 if len(c) > n:
        break len(c) > n len(c) len c n break a += c a c a.sort(reverse=True) a.sort a sort reverse=True reverse True print(sum(a[:n])) print sum(a[:n]) sum a[:n] a :n n n, m = MAP() MAP() n m = MAP() MAP() m def LIST()  : return list(MAP()) def LIST()  : return list(MAP()) LIST c = [] [] c def input() : return sys.stdin.readline().strip() def input() : return sys.stdin.readline().strip() input def MAP()   : return map(int,input().split()) def MAP()   : return map(int,input().split()) MAP b = [LIST() for i in range(m)] [LIST() for i in range(m)] b a = LIST() LIST() a def INT()   : return int(input()) def INT()   : return int(input()) INT c += [b[i][1]]*b[i][0] [b[i][1]]*b[i][0] c a += c c a
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
a = LIST()
b = [LIST() for i in range(m)]
b.sort(key=itemgetter(1), reverse=True)

c = []
for i in range(m):
    c += [b[i][1]]*b[i][0]
    if len(c) > n:
        break

a += c
a.sort(reverse=True)
print(sum(a[:n]))