#include using namespace std; typedef long long ll; const ll INF = 1e+12; #define REP(i, n) for (ll i = 0; i < n; ++i) #define ALL(v) v.begin(), v.end() int main() { ll N, C; cin >> N >> C; vector P(N); REP(n, N) { cin >> P[n]; } sort(ALL(P), greater()); vector cs1, cs2; REP(c, C) { ll T, X; cin >> T >> X; switch (T) { case 1: cs1.push_back(X); break; case 2: cs2.push_back(X); break; } } sort(ALL(cs1), greater()); sort(ALL(cs2), greater()); ll c1 = cs1.size(), c2 = cs2.size(); vector> dp(N + 1, vector(c1 + 1, INF)); dp[0][0] = 0; REP(i, N) { REP(j, c1 + 1) { if (j > i) { continue; } ll k = i - j; dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + P[i]); if (j < c1) { ll cost = max(static_cast(0), P[i] - cs1[j]); dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + cost); } if (k < c2) { ll cost = P[i] - ((P[i] / 100) * cs2[k]); dp[i + 1][j + 0] = min(dp[i + 1][j + 0], dp[i][j] + cost); } } } cout << *min_element(ALL(dp[N])) << endl; return 0; }