You are given circular array a0, a1, ..., an - 1. There are two types of operations with it: 

  * inc(lf, rg, v) — this operation increases each element on the segment [lf, rg] (inclusively) by v; 
  * rmq(lf, rg) — this operation returns minimal value on the segment [lf, rg] (inclusively). 



Assume segments to be circular, so if n = 5 and lf = 3, rg = 1, it means the index sequence: 3, 4, 0, 1.

Write program to process given sequence of operations.

Input

The first line contains integer n (1 ≤ n ≤ 200000). The next line contains initial state of the array: a0, a1, ..., an - 1 ( - 106 ≤ ai ≤ 106), ai are integer. The third line contains integer m (0 ≤ m ≤ 200000), m — the number of operartons. Next m lines contain one operation each. If line contains two integer lf, rg (0 ≤ lf, rg ≤ n - 1) it means rmq operation, it contains three integers lf, rg, v (0 ≤ lf, rg ≤ n - 1; - 106 ≤ v ≤ 106) — inc operation.

Output

For each rmq operation write result for it. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

4
1 2 3 4
4
3 0
3 0 -1
0 1
2 1


Output

1
0
0
import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*;

public class Main {
    static PrintWriter out;
    static Reader in;
    public static void main(String[] args) throws IOException {
        input_output();
        //out = new PrintWriter(System.out);
        //in = new Reader(new FileInputStream("card.in"));
        Main solver = new Main();
        solver.solve();
        out.close(); 
        out.flush(); 
    }

    static long INF = (long)1e18;
    static int maxn = (int)1e7;
    static int mod = (int)1e9+7;
    static int n, m, q, t, k;
    static double pi = 3.141592653589;

    void solve() throws IOException{
    	n = in.nextInt();

    	int[] arr = new int[n];
    	for (int i = 0; i < n; i++) arr[i] = in.nextInt();

    	SegTree st = new SegTree(0, n-1, arr);

    	q = in.nextInt();
    	for (int i = 0; i < q; i++) {
    		String[] s = in.nextLine().split(" ");
    		int[] line = new int[s.length];
    		for (int j = 0; j < s.length; j++) line[j] = Integer.parseInt(s[j]);

    		if (line.length == 2) {
    			if (line[0] <= line[1]) out.println(st.query(line[0], line[1]));
    			else out.println(Math.min(st.query(line[0], n-1), st.query(0, line[1])));
    		} else {
    			if (line[0] <= line[1]) st.update(line[0], line[1], line[2]);
    			else {
    				st.update(line[0], n-1, line[2]);
    				st.update(0, line[1], line[2]);
    			}
    		}
    	}
   	}

    //<>

   	static class SegTree {
        int leftmost, rightmost;
        SegTree lChild, rChild;
        long value;
        long toProp;

        public SegTree(int leftmost, int rightmost, int[] a) {
            this.leftmost=leftmost;
            this.rightmost=rightmost;
            if (leftmost!=rightmost) {
                int mid=(leftmost+rightmost)/2;
                lChild=new SegTree(leftmost, mid, a);
                rChild=new SegTree(mid+1, rightmost, a);
                recalc();
            } else init_leaf(a[leftmost]);
        }
        
        public void init_leaf(int val) {
        	value = val;
        }

        public void recalc() {
            if (leftmost==rightmost) return;
            value = Math.min(lChild.value, rChild.value);
        }
        
        public void prop() {
        	if (toProp == 0) return;

        	value += toProp;
            if (leftmost!=rightmost) {
                lChild.toProp += toProp;
                rChild.toProp += toProp;
            }
            toProp=0;
        }

        public void update(int l, int r, int v) {
            if (l <= leftmost && rightmost <= r) {
            	toProp += v;
                prop();
                return;
            }
            prop();
            if (l>rightmost || r<leftmost) return;
            lChild.update(l, r, v);
            rChild.update(l, r, v);
            recalc();
        }

        public long query(int l, int r) {
        	prop();
            if (l <= leftmost && rightmost <= r) return value;
            if (l > rightmost || r < leftmost) return INF;

			return Math.min(lChild.query(l, r), rChild.query(l, r));
        }
    }

    static class Reader {
 
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
    
        public Reader() {
            this(System.in);
        }
    
        public Reader(InputStream is) {
            mIs = is;
        }
    
        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
    
        }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }
    
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
    
        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
    
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
    
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
    
        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
    
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    
        public boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
 
    }
    static void input_output() throws IOException {
        File f = new File("in.txt");
        if(f.exists() && !f.isDirectory()) { 
            in = new Reader(new FileInputStream("in.txt"));
        } else in = new Reader();
        f = new File("out.txt");
        if(f.exists() && !f.isDirectory()) {
            out = new PrintWriter(new File("out.txt"));
        } else out = new PrintWriter(System.out);
    }
}