Naruto Uzumaki is one of the strongest ninja of RUET (Rasengan University of Ebisu and Tobi), possessing unnaturally huge amount of chakra (a kind of energy). Due to this, he can create a lot of shadow clones (duplicates of himself) with his Shadow Clone Jutsu. Right now, Naruto is bored so he’s just playing around with his shadow clones.
Naruto has already created N shadow clones and lined them up in a row. The i-th clone has Ci amount of chakra in it. Naruto can do the following operations in his whim.
Add V: Makes a new shadow clone with V amount of chakra and adds him to the end of the line.
Remove: Destroys the last shadow clone of the line.
Query LRK – Finds the shadow clone with K-th largest chakra in [L,R] range i.e. the K-th shadow clone if you sort the clones with position between L and R in the line according to their chakra in descending order.
Being a big fan of Naruto, you want to make a video game on Naruto following these 3 operations. In this problem, you have to do exactly that.
Input
The first line contains one integer N (1≤N≤105), the number of shadow clones that has been already created. The next line contains N space separated integers denoting an array A (1≤A[i]≤109). Then there will be an integer Q (1≤Q≤105) - the number of operation Naruto performs. Then next Q lines contains one of the following types:
1 V: Add a shadow clone with V (1≤V≤109) amount chakra to the end of the line
2: Destroys the last shadow clone of the line
3 L R K: Finds the shadow clone with K-th (1≤K≤R−L+1) largest chakra in [L,R] (1≤L,R≤Total Number of Current Shadow Clones) range i.e. the K-th shadow clone if you sort the clones with position between L and R in the line according to their chakra in descending order. It is guaranteed that shadow clones will always exist in [L,R] range.
Output
For each 3rd type of operation you have to print a single integer that denotes the K-th largest chakra in [L,R] range.