n,m=map(int,input().split())
number_dict=dict()
a=list(map(int,input().split()))
for i in a:
  if i in number_dict:
    number_dict[i]+=1
  else:
    number_dict[i]=1

for i in range(m):
  b,c=map(int,input().split())
  if c in number_dict:
    number_dict[c]+=b
  else:
    number_dict[c]=b
number_dict_sort=sorted(number_dict,reverse=True)
#print(number_dict_sort)
#print(number_dict)
ans=0
for i in number_dict_sort:
  #print(i,ans)
  if n-number_dict[i]>=0:
    n-=number_dict[i]
    ans+=i*number_dict[i]
  else:
    ans+=n*i
    break
print(ans)

 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m number_dict=dict() number_dict dict() dict a=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for i in a:
  if i in number_dict:
    number_dict[i]+=1
  else:
    number_dict[i]=1 i a if i in number_dict:
    number_dict[i]+=1
  else:
    number_dict[i]=1 i in number_dict i number_dict number_dict[i]+=1 number_dict[i] number_dict i 1 number_dict[i]=1 number_dict[i] number_dict i 1 for i in range(m):
  b,c=map(int,input().split())
  if c in number_dict:
    number_dict[c]+=b
  else:
    number_dict[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 number_dict:
    number_dict[c]+=b
  else:
    number_dict[c]=b c in number_dict c number_dict number_dict[c]+=b number_dict[c] number_dict c b number_dict[c]=b number_dict[c] number_dict c b number_dict_sort=sorted(number_dict,reverse=True) number_dict_sort sorted(number_dict,reverse=True) sorted number_dict reverse=True reverse True ans=0 ans 0 for i in number_dict_sort:
  #print(i,ans)
  if n-number_dict[i]>=0:
    n-=number_dict[i]
    ans+=i*number_dict[i]
  else:
    ans+=n*i
    break i number_dict_sort if n-number_dict[i]>=0:
    n-=number_dict[i]
    ans+=i*number_dict[i]
  else:
    ans+=n*i
    break n-number_dict[i]>=0 n-number_dict[i] n number_dict[i] number_dict i 0 n-=number_dict[i] n number_dict[i] number_dict i ans+=i*number_dict[i] ans i*number_dict[i] i number_dict[i] number_dict i ans+=n*i ans n*i n i break print(ans) print ans ans+=n*i n*i ans a=list(map(int,input().split())) list(map(int,input().split())) a c=map(int,input().split()) map(int,input().split()) c number_dict=dict() dict() number_dict ans+=i*number_dict[i] i*number_dict[i] ans n,m=map(int,input().split()) map(int,input().split()) n number_dict_sort=sorted(number_dict,reverse=True) sorted(number_dict,reverse=True) number_dict_sort n-=number_dict[i] number_dict[i] n b,c=map(int,input().split()) map(int,input().split()) b ans=0 0 ans m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
number_dict=dict()
a=list(map(int,input().split()))
for i in a:
  if i in number_dict:
    number_dict[i]+=1
  else:
    number_dict[i]=1

for i in range(m):
  b,c=map(int,input().split())
  if c in number_dict:
    number_dict[c]+=b
  else:
    number_dict[c]=b
number_dict_sort=sorted(number_dict,reverse=True)
#print(number_dict_sort)
#print(number_dict)
ans=0
for i in number_dict_sort:
  #print(i,ans)
  if n-number_dict[i]>=0:
    n-=number_dict[i]
    ans+=i*number_dict[i]
  else:
    ans+=n*i
    break
print(ans)


