#include using namespace std; #include using namespace atcoder; using ll = long long; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K, Q; cin >> N >> K >> Q; vector A(N); for(int i = 0; i < N; i++) { cin >> A[i]; } sort(A.begin(), A.end()); priority_queue low; priority_queue, greater> high; for(int i = 0; i < N; i++) { if(i < K) low.push(A[i]); else high.push(A[i]); } while(Q--) { int t; cin >> t; if(t == 1) { ll x; cin >> x; low.push(x); high.push(low.top()); low.pop(); }else if(t == 2) { ll y; cin >> y; ll x = low.top(); low.pop(); if(!high.empty()) { low.push(high.top()); high.pop(); } low.push(x + y); high.push(low.top()); low.pop(); }else { cout << low.top() << "\n"; } } }