#include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i> n >> k >> que; assert(1<=k&&k<=n&&n<=100000); assert(1<=que&&que<=100000); vector a(n); rep(i,n){ cin >> a[i]; assert(1<=a[i]&&a[i]<=1000000000); } sort(a.begin(),a.end()); priority_queue,greater> q; for(int i=k-1;i> t; assert(1<=t&&t<=3); if(t==1){ int x; cin >> x; assert(1<=x&&x<=1000000000); q.push(x); } if(t==2){ int y; cin >> y; assert(1<=y&&y<=1000000000); q.push(q.top()+y); q.pop(); } if(t==3) cout << q.top() << "\n"; } }