n,m=map(int,input().split())
from collections import Counter as co
d=co(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d:d[c]+=b
    else:d[c]=b
f=sorted(d.items(),reverse=1)

now =0
s=0
for k,v in f:
    if now+v<=n:
        now+=v
        s+=k*v
    else:
        
        print(s+(n-now)*k);exit() n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m from collections import Counter as co d=co(list(map(int,input().split()))) d co(list(map(int,input().split()))) co list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in range(m):
    b,c=map(int,input().split())
    if c in d:d[c]+=b
    else:d[c]=b i range(m) range m b,c=map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c if c in d:d[c]+=b
    else:d[c]=b c in d c d f=sorted(d.items(),reverse=1) f sorted(d.items(),reverse=1) sorted d.items() d.items d items reverse=1 reverse 1 now =0 now 0 s=0 s 0 for k,v in f:
    if now+v<=n:
        now+=v
        s+=k*v
    else:
        
        print(s+(n-now)*k);exit() k v f if now+v<=n:
        now+=v
        s+=k*v
    else:
        
        print(s+(n-now)*k);exit() now+v<=n now+v now v n now+=v now v s+=k*v s k*v k v print(s+(n-now)*k) print s+(n-now)*k s (n-now)*k n-now n now k exit() exit d=co(list(map(int,input().split()))) co(list(map(int,input().split()))) d c=map(int,input().split()) map(int,input().split()) c now+=v v now n,m=map(int,input().split()) map(int,input().split()) n s=0 0 s s+=k*v k*v s f=sorted(d.items(),reverse=1) sorted(d.items(),reverse=1) f m=map(int,input().split()) map(int,input().split()) m b,c=map(int,input().split()) map(int,input().split()) b now =0 0 now
n,m=map(int,input().split())
from collections import Counter as co
d=co(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d:d[c]+=b
    else:d[c]=b
f=sorted(d.items(),reverse=1)

now =0
s=0
for k,v in f:
    if now+v<=n:
        now+=v
        s+=k*v
    else:
        
        print(s+(n-now)*k);exit()
