import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long n = sc.nextLong(); int m = sc.nextInt(); Numbers[] numbers = new Numbers[m + 1]; TreeSet set = new TreeSet<>(); for (int i = 1; i <= m; i++) { numbers[i] = new Numbers(i, sc.nextLong()); set.add(numbers[i]); } int q = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int type = sc.nextInt(); int x = sc.nextInt(); long y = sc.nextLong(); if (type == 1) { set.remove(numbers[x]); numbers[x].add(y); set.add(numbers[x]); } else if (type == 2) { set.remove(numbers[x]); numbers[x].add(-y); set.add(numbers[x]); } else { sb.append(set.last()).append("\n"); } } System.out.print(sb); } static class Numbers implements Comparable { int num; long value; public Numbers(int num, long value) { this.num = num; this.value = value; } public int hashCode() { return num; } public boolean equals(Object o) { Numbers x = (Numbers)o; return x.num == num; } public int compareTo(Numbers another) { if (value == another.value) { return num - another.num; } else if (value < another.value) { return -1; } else { return 1; } } public String toString() { return String.valueOf(num); } public void add(long x) { value += x; } } } 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 double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }