#include using namespace std; using ll=long long; namespace Lib{ struct mf_graph{ struct _edge{ int to,rev; ll cap; }; struct edge{ int from,to; ll cap,flow; }; vector> pos; vector> graph; unsigned v_size; mf_graph (int n): graph(n),v_size(n){} void add_edge(int from,int to,ll cap){ pos.push_back({from,(int)graph[from].size()}); graph[from].push_back(_edge({to,(int)graph[to].size(),cap})); graph[to].push_back(_edge({from,(int)graph[from].size()-1,0})); } ll flow(int s,int t){ ll ret=0; vector lev(v_size,-1); auto bfs = [&](int s){ fill(lev.begin(),lev.end(),-1); queueq; lev[s]=0; q.push(s); while(!q.empty()){ int v=q.front(); q.pop(); for(auto e:graph[v]){ if(e.cap>0&&lev[e.to]<0){ lev[e.to]=lev[v]+1; q.push(e.to); } } } }; vector iter(v_size,0); auto dfs = [&](auto self,int v,ll f){ if(v==t)return f; for(int &i=iter[v];i0&&lev[v]0){ e.cap-=d; graph[e.to][e.rev].cap+=d; return d; } } } return 0ll; }; while(1){ bfs(s); if(lev[t]<0)return ret; fill(iter.begin(),iter.end(),0); ll f=0; while((f=dfs(dfs,s,LLONG_MAX))>0){ ret+=f; } } } vector edges(){ vectorret; for(auto i:pos){ auto e=graph[i[0]][i[1]],re=graph[e.to][e.rev]; ret.push_back(edge({i[0],e.to,e.cap+re.cap,re.cap})); } return ret; } }; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; Lib::mf_graph G(2+N+M); for(int i=0;i>A; G.add_edge(i+2,1,A); } vector B(M,0ll); for(ll &i:B)cin>>i; ll inf_flow=1e18; for(int i=0;i>K; G.add_edge(0,2+N+i,B[i]); for(int j=0;j>C; G.add_edge(2+N+i,2+C-1,inf_flow); } } ll ans=accumulate(B.begin(),B.end(),0ll)-G.flow(0,1); cout<