n, c = map(int, input().split()) prices = [int(input()) for _ in range(n)] coupons = [tuple(map(int, input().split())) for _ in range(c)] edges = [] for i in range(n): p = prices[i] for j in range(c): t, x = coupons[j] if t == 1: s = min(x, p) else: s = (p * x) // 100 if s > 0: edges.append((-s, i, j)) # Store negative for ascending sort edges.sort() used_p = [False] * n used_c = [False] * c total_savings = 0 for e in edges: s = -e[0] i = e[1] j = e[2] if not used_p[i] and not used_c[j]: total_savings += s used_p[i] = True used_c[j] = True print(sum(prices) - total_savings)