#include "bits/stdc++.h" using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = 998244353; // dp[i][j] := i番目の商品まで見て, 円引クーポンをj個用いているときの最小の合計金額 ll dp[5010][5010]; signed main() { ios::sync_with_stdio(false); cin.tie(0); ll N, C; cin >> N >> C; vectorP(N); for (int i = 0; i < N; i++)cin >> P[i]; sort(P.rbegin(), P.rend()); vectora, b; for (int i = 0; i < C; i++) { ll T, X; cin >> T >> X; if (T == 1)a.push_back(X); else b.push_back(X); } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); int sa = a.size(), sb = b.size(); for (int i = 0; i < 5010; i++) { for (int j = 0; j < 5010; j++) { dp[i][j] = INF; } } dp[0][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= sa; j++) { if (j < sa) { dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + max(0LL, P[i] - a[j])); } if (0 <= i - j && i - j < sb) { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + P[i] * (100 - b[i - j]) / 100); } dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + P[i]); } } ll ans = INF; for (int j = 0; j <= sa; j++) { ans = min(ans, dp[N][j]); } cout << ans << endl; return 0; }