import java.util.*; import java.io.*; import java.math.*; import java.util.stream.*; import java.util.function.*; class Main implements Runnable { class SegmentTree { private int n ; private T init ; private T [] tree ; private int size ; private BinaryOperator op ; @SuppressWarnings ("unchecked") SegmentTree(int size , T init , BinaryOperator op) { this.size = size; this.init = init ; this.op = op ; n = 1 ; while(n <= size) n *= 2 ; this.tree = (T []) new Object[2 * n]; for(int i = 0 ; i < 2 * n ; i ++ ) tree[i] = init ; } public void update(int index , T value) { index += n ; tree[index] = value ; while(index > 0) { index /= 2 ; tree[index] = op.apply(tree[2 * index] , tree[2 * index + 1]); } } public T query(int l , int r){ l += n ; r += n ; T res = init ; while(l < r){ if(l % 2 == 1){ res = op.apply(res , tree[l]) ; l ++ ; } l /= 2 ; if(r % 2 == 1){ res = op.apply(res , tree[r - 1]) ; r -- ; } r /= 2 ; } return res ; } public String debug() { StringBuilder sb = new StringBuilder(); for(int i = n ; i < n + size ; i ++ ) sb.append(tree[i]+" "); return sb.toString() ; } } class Compress { private TreeSet order ; private Map comp ; private int count ; Compress(List L) { this.order = new TreeSet<>(L) ; this.comp = new HashMap<>(); this.count = 0 ; for(T v : order) comp.put(v , count++); } public int get(T value) { return comp.get(value); } public int size() { return order.size(); } } record P(long fi , long se) { } public void solve(){ long n = in.nextLong() ; int m = in.nextInt(); long [] a = in.nextLong(m); Set S = new HashSet<>(); for(long i = 1 ; i <= m ; i ++) S.add(i); List> query = new ArrayList<>(); int q = in.nextInt(); for(int i = 0 ; i < q ; i ++){ int t = in.nextInt() ; long x = in.nextLong() , y = in.nextLong(); query.add(new Trio<>(t , x , y)); S.add(x); } Compress Comp = new Compress<>(new ArrayList<>(S)); SegmentTree

seg = new SegmentTree<>(Comp.size() , new P(0 , 0) , (x , y) -> { if(x.se < y.se) return y ; else if(x.se > y.se) return x; return x.fi < y.fi ? y : x ; }); for(long i = 1 ; i <= m ; i ++) { int id = Comp.get(i); long count = seg.query(id , id + 1).se ; seg.update(id , new P(id , count + a[(int)i - 1])); } for(int i = 0 ; i < q ; i ++) { var que = query.get(i); int id = Comp.get(que.se); long count = seg.query(id , id + 1).se ; if(que.fi == 1) { seg.update(id , new P(id , count + que.th)); } if(que.fi == 2) { seg.update(id , new P(id , count - que.th)); } if(que.fi == 3) { print(seg.query(0 , Comp.size()).fi); } } } public record Pair (T fi , S se) { public String toString() { return "("+fi+","+se+")"; } } public record Trio(T fi , S se , U th) { public String toString() { return "("+fi+","+se+","+th+")"; } } public PrintWriter out = new PrintWriter(System.out); public In in = new In(); public static final int mod7 = 1000000007; public static final int mod9 = 998244353; public static final int inf = (1 << 30); public static final long lnf = (1L << 60); public static final String yes = "Yes"; public static final String no = "No" ; public static final int [] dy4 = {-1,0,1,0}; public static final int [] dx4 = {0,1,0,-1}; public static final int [] dy8 = {-1,-1,-1,0,1,1,1,0}; public static final int [] dx8 = {-1,0,1,1,1,0,-1,-1}; public boolean isOver(int y , int x , int h , int w) { return y < 0 || x < 0 || y >= h || x >= w ; } public void swap(int [] array , int l , int r) { int tmp = array[l] ; array[l] = array[r] ; array[r] = tmp ; } public void swap(long [] array , int l , int r) { long tmp = array[l] ; array[l] = array[r] ; array[r] = tmp ; } public String swap(String string , int l , int r) { StringBuilder m = new StringBuilder(string) ; m.setCharAt(l, string.charAt(r)); m.setCharAt(r, string.charAt(l)); return m.toString(); } public String binarytoString(int a , int len) { String b = Integer.toBinaryString(a); while(b.length() < len) b = "0" + b ; return b ; } public String binarytoString(long a , int len) { String b = Long.toBinaryString(a); while(b.length() < len) b = "0" + b ; return b ; } public > int LowCountClosed(List A , T key) { return upperbound(A, key); } public > int LowCountOpen(List A , T key) { return lowerbound(A, key); } public > int HighCountClosed(List A , T key) { return A.size() - lowerbound(A, key); } public > int HighCountOpen(List A , T key) { return A.size() - upperbound(A, key); } // [) public > int CountClosedOpen(List A, T a, T b) { return lowerbound(A, b) - lowerbound(A, a); } // [] public > int CountClosedClosed(List A, T a, T b) { return upperbound(A, b) - lowerbound(A, a); } // (] public > int CountOpenClosed(List A, T a, T b) { return upperbound(A, b) - upperbound(A, a); } // () public > int CountOpenOpen(List A, T a, T b) { return lowerbound(A, b) - upperbound(A, a); } private > int lowerbound(List A, T key) { int left = 0 , right = A.size(); while (left < right) { int mid = (left + right) / 2; if (A.get(mid).compareTo(key) < 0) left = mid + 1; else right = mid; } return right; } private > int upperbound(List A, T key) { int left = 0 , right = A.size(); while (left < right) { int mid = (left + right) / 2; if (A.get(mid).compareTo(key) <= 0) left = mid + 1; else right = mid; } return right; } public Integer [] toInteger(int [] a) { return Arrays.stream(a).boxed().toArray(Integer[]::new); } public Long [] toLong(long [] a) { return Arrays.stream(a).boxed().toArray(Long[]::new); } public Double [] toDouble(double [] a) { return Arrays.stream(a).boxed().toArray(Double[]::new); } public List ArrayList(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(ArrayList::new)); } public HashSet HashSet(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(HashSet::new)); } public TreeSet TreeSet(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(TreeSet::new)); } public Deque Deque(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(ArrayDeque::new)); } public PriorityQueue PriorityQueue(T [] a) { return Arrays.stream(a).collect(Collectors.toCollection(PriorityQueue::new)); } public List [] ArrayList(int n) { @SuppressWarnings("unchecked") List [] G = new ArrayList[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new ArrayList<>(); return G ; } public HashSet [] HashSet(int n) { @SuppressWarnings("unchecked") HashSet [] G = new HashSet[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new HashSet<>() ; return G ; } public TreeSet [] TreeSet(int n) { @SuppressWarnings("unchecked") TreeSet [] G = new TreeSet[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeSet<>() ; return G ; } public TreeSet [] TreeSet(int n , Comparator comparator) { @SuppressWarnings("unchecked") TreeSet [] G = new TreeSet[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeSet<>(comparator) ; return G ; } public Deque [] Deque(int n) { @SuppressWarnings("unchecked") Deque [] G = new ArrayDeque[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new ArrayDeque<>(); return G ; } public PriorityQueue [] PriorityQueue(int n) { @SuppressWarnings("unchecked") PriorityQueue [] G = new PriorityQueue[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new PriorityQueue<>(); return G ; } public PriorityQueue [] PriorityQueue(int n , Comparator comparator) { @SuppressWarnings("unchecked") PriorityQueue [] G = new PriorityQueue[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new PriorityQueue<>(comparator); return G ; } public HashMap [] HashMap(int n) { @SuppressWarnings("unchecked") HashMap [] G = new HashMap[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new HashMap<>() ; return G ; } public TreeMap [] TreeMap(int n) { @SuppressWarnings("unchecked") TreeMap [] G = new TreeMap[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeMap<>() ; return G ; } public TreeMap [] TreeMap(int n , Comparator comparator) { @SuppressWarnings("unchecked") TreeMap [] G = new TreeMap[n]; for(int i = 0 ; i < n ; i ++ ) G[i] = new TreeMap<>(comparator) ; return G ; } //---------------------------------------------------------------------------------------// @SuppressWarnings("unchecked") public void print(T ... data) { StringBuilder pr = new StringBuilder(); for(var temp : data) pr.append(temp+" "); out.println(pr.toString()); out.flush(); } public void print(String [][] array) { StringBuilder pr = new StringBuilder(); for(var temp : array) { for(var data : temp) { pr.append(data+" "); } pr.append("\n"); } if(0 < pr.length()) pr.deleteCharAt(pr.length() - 1); out.println(pr.toString()); out.flush(); } public void print(char [][] array) { StringBuilder pr = new StringBuilder(); for(var temp : array) { for(var data : temp) { pr.append(data); } pr.append("\n"); } if(0 < pr.length()) pr.deleteCharAt(pr.length() - 1); out.println(pr.toString()); out.flush(); } public void print(Collection collection) { StringBuilder pr = new StringBuilder(); for(T data : collection) pr.append(data +" "); out.println(pr.toString()); out.flush(); } public static void main(String ... args) { new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start(); } public void run() { solve(); out.flush(); } } class In { private final InputStream in = System.in; private final Scanner sc = new Scanner(System.in); private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) { ptr++; } return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } public char nextChar() { return next().charAt(0); } public BigInteger nexBigInteger() { return sc.nextBigInteger(); } public int [] nextInt(int n) { int [] array = new int[n]; for(int i = 0 ; i < n ; i ++) { array[i] = nextInt(); } return array ; } public int [][] nextInt(int n , int m) { int [][] array = new int[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = nextInt(m); } return array ; } public long [] nextLong(int n) { long [] array = new long[n]; for(int i = 0 ; i < n ; i ++) { array[i] = nextLong(); } return array ; } public long [][] nextLong(int n , int m) { long [][] array = new long[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = nextLong(m); } return array ; } public double [] nextDouble(int n) { double [] array = new double[n]; for(int i = 0 ; i < n ; i ++) { array[i] = nextDouble(); } return array ; } public String [] next(int n) { String [] array = new String[n]; for(int i = 0 ; i < n ; i ++) { array[i] = next(); } return array ; } public String [][] next(int n , int m) { String [][] array = new String[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = next(m); } return array ; } public char [] nextChar(int n) { char [] array = new char[n]; String string = next() ; for(int i = 0 ; i < n ; i ++) { array[i] = string.charAt(i); } return array ; } public char [][] nextChar(int n , int m) { char [][] array = new char[n][m]; for(int i = 0 ; i < n ; i ++) { array[i] = nextChar(m); } return array ; } }