N, C = map(int, input().split()) P = [int(input()) for i in range(N)] Cs = [list(map(int, input().split())) for i in range(C)] P.sort(reverse = True) ans = sum(P) used = [0] * C for i in range(N): maxd = 0 use = -1 for j in range(C): if used[j]: continue if Cs[j][0] == 1: d = P[i] - max(P[i] - Cs[j][1], 0) else: d = P[i] * Cs[j][1] //100 if d > maxd: use = j maxd = d used[use] = 1 ans -= maxd print(ans)