n,m=map(int,input().split())
a=[0]*n
List={}
a=list(map(int,input().split()))
for i in range(n):
  List.setdefault(a[i],0)
  List[a[i]]+=1
ans=0

for i in range(m):
  b,c=map(int,input().split())
  List.setdefault(c,0)
  List[c]+=b
  
List_sorted=sorted(List, reverse=True)

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

for i in range(m):
  b,c=map(int,input().split())
  List.setdefault(c,0)
  List[c]+=b
  
List_sorted=sorted(List, reverse=True)

#print(List)
#print(List_sorted)
for i in List_sorted:
  if (List[i]<n):
    ans+=i*List[i]
    n-=List[i]
  else:
    ans+=i*n
    break
    
print(ans)