from heapq import heapify, heappop, heappush N,C = map(int, input().split()) P = [] for _ in range(N): p = int(input()) P.append(p) P.sort(reverse = True) T = []; X = [] for _ in range(C): t,x = map(int,input().split()) T.append(t); X.append(x) Fix = [] Percent = [] for i in range(C): if T[i] == 1: heappush(Fix, -X[i]) #大きい順に取り出したいのでマイナス else: heappush(Percent, -X[i]) ans = 0 for i in range(N): if len(Fix) == 0 and len(Percent) == 0: ans += P[i] elif len(Percent) == 0: discount = -Fix[0] ans += max(0, P[i] - discount) heappop(Fix) elif len(Fix) == 0: ans += P[i]*(100+Percent[0])//100 heappop(Percent) else: discount = -Fix[0] fix_price = max(P[i] - discount, 0) per_price = P[i]*(100 + Percent[0])//100 #print(fix_price,per_price,Percent[0]) if per_price <= fix_price: #%を採用 ans += per_price heappop(Percent) else: ans += fix_price heappop(Fix) print(ans)