import java.io.*; import java.util.*; public class Main { static long[] counts; static Num[] nums; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long n = sc.nextLong(); int m = sc.nextInt(); TreeSet stock = new TreeSet<>(); counts = new long[m]; nums = new Num[m]; for (int i = 0; i < m; i++) { nums[i] = new Num(i); counts[i] = sc.nextLong(); stock.add(nums[i]); } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int type = sc.nextInt(); int x = sc.nextInt() - 1; long y = sc.nextLong(); if (type == 1) { stock.remove(nums[x]); counts[x] += y; stock.add(nums[x]); } else if (type == 2) { stock.remove(nums[x]); counts[x] -= y; stock.add(nums[x]); } else { sb.append(stock.last()).append("\n"); } } System.out.print(sb); } static class Num implements Comparable { int idx; public Num(int idx) { this.idx = idx; } public int compareTo(Num another) { if (counts[idx] == counts[another.idx]) { return idx - another.idx; } else if (counts[idx] > counts[another.idx]) { return 1; } else { return -1; } } public int hashCode() { return idx; } public String toString() { return String.valueOf(idx + 1); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }