import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n,m = rl()
a = rl()

li=dict(Counter(a))
for _ in range(m):
    b, c = rl()
    if c in li:
        li[c]+=b
    else:
        li[c]=b
li=sorted(li.items(),key=lambda x: -x[0])
ans=0
res=n
for pair in li:
    if res<=0:
        continue
    if res>=pair[1]:
        ans+=pair[0]*pair[1]
        res-=pair[1]
    else:
        ans+=pair[0]*res
        res=0
print(ans) import sys sys from collections import deque, Counter, defaultdict import math math input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(10**8) sys.setrecursionlimit sys setrecursionlimit 10**8 10 8 inf = 10**18 inf 10**18 10 18 MOD = 1000000007 MOD 1000000007 ri = lambda : int(input()) ri lambda : int(input()) int(input()) int input() input rs = lambda : input().strip() rs lambda : input().strip() input().strip() ().strip () input strip rl = lambda : list(map(int, input().split())) rl lambda : list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split n,m = rl() n rl() rl m a = rl() a rl() rl li=dict(Counter(a)) li dict(Counter(a)) dict Counter(a) Counter a for _ in range(m):
    b, c = rl()
    if c in li:
        li[c]+=b
    else:
        li[c]=b _ range(m) range m b, c = rl() b rl() rl c if c in li:
        li[c]+=b
    else:
        li[c]=b c in li c li li[c]+=b li[c] li c b li[c]=b li[c] li c b li=sorted(li.items(),key=lambda x: -x[0]) li sorted(li.items(),key=lambda x: -x[0]) sorted li.items() li.items li items key=lambda x: -x[0] key lambda x: -x[0] -x[0] x[0] x 0 x ans=0 ans 0 res=n res n for pair in li:
    if res<=0:
        continue
    if res>=pair[1]:
        ans+=pair[0]*pair[1]
        res-=pair[1]
    else:
        ans+=pair[0]*res
        res=0 pair li if res<=0:
        continue
     res<=0 res 0 continue if res>=pair[1]:
        ans+=pair[0]*pair[1]
        res-=pair[1]
    else:
        ans+=pair[0]*res
        res=0 res>=pair[1] res pair[1] pair 1 ans+=pair[0]*pair[1] ans pair[0]*pair[1] pair[0] pair 0 pair[1] pair 1 res-=pair[1] res pair[1] pair 1 ans+=pair[0]*res ans pair[0]*res pair[0] pair 0 res res=0 res 0 print(ans) print ans b, c = rl() rl() b c = rl() rl() c m = rl() rl() m li=dict(Counter(a)) dict(Counter(a)) li res=n n res res-=pair[1] pair[1] res MOD = 1000000007 1000000007 MOD ri = lambda : int(input()) lambda : int(input()) ri li=sorted(li.items(),key=lambda x: -x[0]) sorted(li.items(),key=lambda x: -x[0]) li a = rl() rl() a ans+=pair[0]*res pair[0]*res ans rs = lambda : input().strip() lambda : input().strip() rs n,m = rl() rl() n rl = lambda : list(map(int, input().split())) lambda : list(map(int, input().split())) rl res=0 0 res ans+=pair[0]*pair[1] pair[0]*pair[1] ans ans=0 0 ans input = sys.stdin.readline sys.stdin.readline input inf = 10**18 10**18 inf
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n,m = rl()
a = rl()

li=dict(Counter(a))
for _ in range(m):
    b, c = rl()
    if c in li:
        li[c]+=b
    else:
        li[c]=b
li=sorted(li.items(),key=lambda x: -x[0])
ans=0
res=n
for pair in li:
    if res<=0:
        continue
    if res>=pair[1]:
        ans+=pair[0]*pair[1]
        res-=pair[1]
    else:
        ans+=pair[0]*res
        res=0
print(ans)