n,C = map(int,input().split()) p = [int(input()) for _ in range(n)] const = [] per = [] for _ in range(C): t,x = map(int,input().split()) if t==1: const.append(x) else: per.append(x) p.sort(reverse=1) const.sort(reverse=1) per.sort(reverse=1) Lc,Lp = len(const), len(per) """ dp[i][j] = i 個処理してconst を j 枚使った, つまり per は i-j 枚使った """ 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 i < j: break if i-j >= Lp: continue v = dp[j] + pi//100*(100-per[i-j]) ndp[j] = min(ndp[j],v) for j in range(1,Lc+1): v = dp[j-1] + max(pi-const[j-1],0) ndp[j] = min(ndp[j],v) dp = ndp #print(dp) print(min(dp))