#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() using ll=long long int; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end ll dp[5010][5010]; int main(){ int n,m; cin>>n>>m; vector p(n); rep(i,0,n)cin>>p[i]; sort(ALL(p),greater()); vector cs[2]; rep(i,0,m){ int t,x; cin>>t>>x; t--; cs[t].push_back(x); } rep(i,0,2){ sort(ALL(cs[i]),greater()); cs[i].resize(n+1); } rep(i,0,n+1)rep(j,0,n+1)dp[i][j]=INF; dp[0][0]=0; rep(i,0,n)rep(j,0,n)if(dp[i][j]!=INF){ if(i+j==n)continue; chmin(dp[i+1][j],dp[i][j]+max(0,p[i+j]-cs[0][i])); chmin(dp[i][j+1],dp[i][j]+p[i+j]/100*(100-cs[1][j])); } ll res=INF; rep(i,0,n+1)chmin(res,dp[i][n-i]); cout<