n,C = map(int,input().split()) p = sorted(int(input()) for _ in range(n))[::-1] R = [] S = [] for _ in range(C): t,x = map(int,input().split()) if t==1: R.append(x) else: S.append(x) R.sort(reverse=1) S.sort(reverse=1) Lc,Lp = len(R), len(S) INF = 10**18 dp = [INF]*(Lc+1) dp[0] = 0 for i,pi in enumerate(p): ndp = [x+pi for x in dp] for j in range(Lc+1): if j: ndp[j] = min(ndp[j], dp[j-1] + max(pi-R[j-1],0)) if 0 <= i-j < Lp: ndp[j] = min(ndp[j], dp[j] + pi//100*(100-S[i-j])) dp = ndp print(min(dp))