#include using namespace std; #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=2e9+1; const ll INF=4e18; const ll dy[8]={-1,0,1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; template inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } int main(){ ll n,c;cin >> n >> c; vl v(n);rep(i,n)cin >> v[i]; sort(all(v));rev(all(v)); vl x,p; rep(i,c){ ll t,a;cin >> t >> a; if(t==1){ x.emplace_back(a); } else p.emplace_back(a); } sort(all(x));rev(all(x)); sort(all(p));rev(all(p)); vvl dp(x.size()+1,vl(p.size()+1)); rep(i,x.size()+1){ rep(j,p.size()+1){ if(i+j>=n)continue; if(i!=x.size()){ chmax(dp[i+1][j],dp[i][j]+min(v[i+j],x[i])); } if(j!=p.size()){ chmax(dp[i][j+1],dp[i][j]+v[i+j]/100*p[j]); } } } ll ans=0;rep(i,x.size()+1)rep(j,p.size()+1)chmax(ans,dp[i][j]); //cout << ans << endl; cout << accumulate(all(v),0LL)-ans << endl; }