n,m=map(int,input().split())
a=list(map(int,input().split()))
d={}
for i in a:
  d[i]=d.get(i,0)+1

for _ in range(m):
    b,c=map(int,input().split())
    d[c]=d.get(c,0)+b
e=list(d.keys())
e.sort()
ans=f=0
for i in e[::-1]:
    if f+d[i]>=n:
        ans+=i*(n-f)
        break
    ans+=i*d[i]
    f+=d[i]
print(ans) n,m=map(int,input().split()) n 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 d={} d {} for i in a:
  d[i]=d.get(i,0)+1 i a d[i]=d.get(i,0)+1 d[i] d i d.get(i,0)+1 d.get(i,0) d.get d get i 0 1 for _ in range(m):
    b,c=map(int,input().split())
    d[c]=d.get(c,0)+b _ range(m) range m b,c=map(int,input().split()) b map(int,input().split()) map int input().split() ().split () input split c d[c]=d.get(c,0)+b d[c] d c d.get(c,0)+b d.get(c,0) d.get d get c 0 b e=list(d.keys()) e list(d.keys()) list d.keys() d.keys d keys e.sort() e.sort e sort ans=f=0 ans 0 =f=0 f 0 for i in e[::-1]:
    if f+d[i]>=n:
        ans+=i*(n-f)
        break
    ans+=i*d[i]
    f+=d[i] i e[::-1] e ::-1 -1 if f+d[i]>=n:
        ans+=i*(n-f)
        break
     f+d[i]>=n f+d[i] f d[i] d i n ans+=i*(n-f) ans i*(n-f) i n-f n f break ans+=i*d[i] ans i*d[i] i d[i] d i f+=d[i] f d[i] d i print(ans) print ans ans=f=0 0 ans ans+=i*d[i] i*d[i] ans f+=d[i] d[i] f f=0 0 f ans+=i*(n-f) i*(n-f) ans n,m=map(int,input().split()) map(int,input().split()) n b,c=map(int,input().split()) map(int,input().split()) b d={} {} d e=list(d.keys()) list(d.keys()) e a=list(map(int,input().split())) list(map(int,input().split())) a m=map(int,input().split()) map(int,input().split()) m c=map(int,input().split()) map(int,input().split()) c
n,m=map(int,input().split())
a=list(map(int,input().split()))
d={}
for i in a:
  d[i]=d.get(i,0)+1

for _ in range(m):
    b,c=map(int,input().split())
    d[c]=d.get(c,0)+b
e=list(d.keys())
e.sort()
ans=f=0
for i in e[::-1]:
    if f+d[i]>=n:
        ans+=i*(n-f)
        break
    ans+=i*d[i]
    f+=d[i]
print(ans)