from collections import Counter
n,m=map(int,input().split())
d=Counter(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d.keys():
        d[c]+=b
    else:
        d[c]=b
d=sorted(d.items(),reverse=True)
check=n
ans=0
for i in d:
    if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break from collections import Counter n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m d=Counter(list(map(int,input().split()))) d Counter(list(map(int,input().split()))) Counter 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.keys():
        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.keys():
        d[c]+=b
    else:
        d[c]=b c in d.keys() c d.keys() d.keys d keys d[c]+=b d[c] d c b d[c]=b d[c] d c b d=sorted(d.items(),reverse=True) d sorted(d.items(),reverse=True) sorted d.items() d.items d items reverse=True reverse True check=n check n ans=0 ans 0 for i in d:
    if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break i d if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break i[1]<check i[1] i 1 check check-=i[1] check i[1] i 1 ans+=(i[0]*i[1]) ans i[0]*i[1] i[0] i 0 i[1] i 1 ans+=(i[0]*check) ans i[0]*check i[0] i 0 check print(ans) print ans break n,m=map(int,input().split()) map(int,input().split()) n ans=0 0 ans b,c=map(int,input().split()) map(int,input().split()) b check-=i[1] i[1] check m=map(int,input().split()) map(int,input().split()) m ans+=(i[0]*check) i[0]*check ans check=n n check ans+=(i[0]*i[1]) i[0]*i[1] ans c=map(int,input().split()) map(int,input().split()) c d=sorted(d.items(),reverse=True) sorted(d.items(),reverse=True) d d=Counter(list(map(int,input().split()))) Counter(list(map(int,input().split()))) d
from collections import Counter
n,m=map(int,input().split())
d=Counter(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d.keys():
        d[c]+=b
    else:
        d[c]=b
d=sorted(d.items(),reverse=True)
check=n
ans=0
for i in d:
    if i[1]<check:
        check-=i[1]
        ans+=(i[0]*i[1])
    else:
        ans+=(i[0]*check)
        print(ans)
        break