N,C=map(int,input().split()) P=[int(input()) for i in range(N)] disc=[] disc_per=[] P.sort(reverse=True) for i in range(C): t,x=map(int,input().split()) if t==1: disc.append(x) else: disc_per.append(x) disc_per.sort(reverse=True) disc.sort(reverse=True) posi,posi_per=0,0 ans=0 for j,i in enumerate(P): if len(disc)<=posi and len(disc_per)<=posi_per: ans+=i continue if len(disc)<=posi: pt1=i else: pt1=max(i-disc[posi],0) if len(disc_per)<=posi_per: pt2=i else: pt2=max(i*(100-disc_per[posi_per])//100,0) if pt1>pt2: posi_per+=1 ans+=pt2 elif pt2>pt1: posi+=1 ans+=pt1 else: if j==len(P)-1: ans+=pt1 break else: ans+=pt1 next=P[j+1] if len(disc)<=posi+1: pt1=i else: pt1=max(next-disc[posi+1],0) if len(disc_per)<=posi_per+1: pt2=i else: pt2=max(next*(100-disc_per[posi_per+1])//100,0) if pt1