n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
from itertools import accumulate
from bisect import bisect_left
from collections import Counter
dic=Counter(a)
for i in range(m):
  b,c=list(map(int,input().split()))
  dic[c]=dic.get(c,0)+b

dic=sorted(dic.items(),key=lambda x:x[0],reverse=True)

ans=0
num=0
for i in dic:
  num=num+i[1]
  ans=ans+i[0]*i[1]
  if num>=n:
    r=i[0]
    break
 
print(ans-(num-n)*r)


   n,m=list(map(int,input().split())) n list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split m a=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split from itertools import accumulate from bisect import bisect_left from collections import Counter dic=Counter(a) dic Counter(a) Counter a for i in range(m):
  b,c=list(map(int,input().split()))
  dic[c]=dic.get(c,0)+b i range(m) range m b,c=list(map(int,input().split())) b list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c dic[c]=dic.get(c,0)+b dic[c] dic c dic.get(c,0)+b dic.get(c,0) dic.get dic get c 0 b dic=sorted(dic.items(),key=lambda x:x[0],reverse=True) dic sorted(dic.items(),key=lambda x:x[0],reverse=True) sorted dic.items() dic.items dic items key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x reverse=True reverse True ans=0 ans 0 num=0 num 0 for i in dic:
  num=num+i[1]
  ans=ans+i[0]*i[1]
  if num>=n:
    r=i[0]
    break
  i dic num=num+i[1] num num+i[1] num i[1] i 1 ans=ans+i[0]*i[1] ans ans+i[0]*i[1] ans i[0]*i[1] i[0] i 0 i[1] i 1 if num>=n:
    r=i[0]
    break
  num>=n num n r=i[0] r i[0] i 0 break print(ans-(num-n)*r) print ans-(num-n)*r ans (num-n)*r num-n num n r b,c=list(map(int,input().split())) list(map(int,input().split())) b n,m=list(map(int,input().split())) list(map(int,input().split())) n a=list(map(int,input().split())) list(map(int,input().split())) a r=i[0] i[0] r dic=sorted(dic.items(),key=lambda x:x[0],reverse=True) sorted(dic.items(),key=lambda x:x[0],reverse=True) dic m=list(map(int,input().split())) list(map(int,input().split())) m num=0 0 num dic=Counter(a) Counter(a) dic c=list(map(int,input().split())) list(map(int,input().split())) c num=num+i[1] num+i[1] num ans=0 0 ans ans=ans+i[0]*i[1] ans+i[0]*i[1] ans
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
from itertools import accumulate
from bisect import bisect_left
from collections import Counter
dic=Counter(a)
for i in range(m):
  b,c=list(map(int,input().split()))
  dic[c]=dic.get(c,0)+b

dic=sorted(dic.items(),key=lambda x:x[0],reverse=True)

ans=0
num=0
for i in dic:
  num=num+i[1]
  ans=ans+i[0]*i[1]
  if num>=n:
    r=i[0]
    break
 
print(ans-(num-n)*r)


  
