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.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.TreeSet;

public class Solution {
	
	static InputReader in = new InputReader();
	static PrintWriter out = new PrintWriter(System.out);
	
	//static final int mod = 1000000000;
	static int n,q;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		n = in.nextInt();
		int[] A = in.nextArray(n);
		
		LST lst = new LST(A);
		
		int q = in.nextInt();
		for(int lul=0; lul<q; lul++) {
			String line = in.nextLine();
			String[] arg = line.split(" ");
			if(arg.length==2) {
				int l = Integer.parseInt(arg[0]);
				int r = Integer.parseInt(arg[1]);
				if(l>r) {
					int val1 = (int) lst.query(0, r);
					int val2 = (int) lst.query(l,n-1);
					out.println(Math.min(val1, val2));
				} else {
					out.println(lst.query(l, r));
				}
			} else {
				int l = Integer.parseInt(arg[0]);
				int r = Integer.parseInt(arg[1]);
				int v = Integer.parseInt(arg[2]);
				if(l>r) {
					lst.update(l, n-1, v);
					lst.update(0, r, v);
				} else {
					lst.update(l, r, v);
				}
				
			}
		}
		out.flush();
	}  
	
	static class LST {
		private int[] arr;
		private long[] tree;
		private int[] lazy;
		// ******************************************************************* //
		// CHANGE HERE.
		// 0-based indexing.
		// Currently: Query operation takes MIN of the given range.
		//            Update operation increases the given range by the value.	
		//            Set operation sets the given index to the value.
		final int DEFAULT_QUERY = Integer.MAX_VALUE;
		final int DEFAULT_LAZY = 0;
		
		void preprocess() {
			
		}

		void baseCase(int i, int l, int val) {
			tree[i] = val;
		}
		
		void beforeTreeUpdate(int node, int l, int r) {
			
		}
		
		long op(long a, long b) {
			return Math.min(a, b);
		}
		
		void updateLazy(int node, int l, int r, int val) {
			lazy[node] += val;
			tree[node] += val;
		}
		// ******************************************************************* //

		public LST(int[] arr) {
			this.arr = arr;
			tree = new long[arr.length<<2];
			lazy = new int[arr.length<<2];
			for (int i = 0; i < lazy.length; i++) lazy[i] = DEFAULT_LAZY;
			preprocess();
			build(1, 0, arr.length-1);
		}

		public void set(int idx, int val) {
			query(idx, idx);
			set(idx, val, 1, 0, arr.length-1);
		}

		public void update(int ql, int qr, int val) {
			updateUtil(ql, qr, val, 1, 0, arr.length-1);
		}

		public long query(int l, int r) {
			return queryUtil(l, r, 1, 0, arr.length-1);
		}

		private void build(int node, int l, int r) {
			if (l == r) {
				baseCase(node, l, arr[l]);
				return;
			}
			int m = (l+r+1) / 2;
			build(2*node, l, m-1);
			build(2*node + 1, m, r);
			beforeTreeUpdate(node, l, r);
			tree[node] = op(tree[2*node], tree[2*node + 1]);
		}

		private void set(int idx, int val, int node, int l, int r) {
			if (l == r) {
				baseCase(node, l, val);
				return;
			}
			int m = (l+r+1) / 2;
			if (idx < m) set(idx, val, 2*node, l, m-1);
			else set(idx, val, 2*node + 1, m, r);
			beforeTreeUpdate(node, l, r);
			tree[node] = op(tree[2*node], tree[2*node + 1]);
		}

		private void updateUtil(int ql, int qr, int val, int node, int l, int r) {
			if (qr < l || ql > r) return;
			if (qr >= r && ql <= l) {
				updateLazy(node, l, r, val);
				return;
			}
			propagateLazy(node, l, r);
			int m = (l+r+1) / 2;
			updateUtil(ql, qr, val, 2*node, l, m-1);
			updateUtil(ql, qr, val, 2*node + 1, m, r);
			beforeTreeUpdate(node, l, r);
			tree[node] = op(tree[2*node], tree[2*node + 1]);
		}

		private long queryUtil(int ql, int qr, int node, int l, int r) {
			if (qr < l || ql > r) return DEFAULT_QUERY;
			if (qr >= r && ql <= l) {
				return tree[node];
			}
			propagateLazy(node, l, r);
			int m = (l+r+1) / 2;
			return op(queryUtil(ql, qr, 2*node, l, m-1),
					queryUtil(ql, qr, 2*node + 1, m, r));
		}

		private void propagateLazy(int node, int l, int r) {
			int m = (l+r+1) / 2;
			updateLazy(2*node, l, m-1, lazy[node]);
			updateLazy(2*node + 1, m, r, lazy[node]);
			lazy[node] = DEFAULT_LAZY;
		}
	}
	
	static class InputReader {
			private InputStream stream;
			private byte[] buf = new byte[1024];
			private int curChar;
			private int numChars;

			public InputReader(InputStream stream) {
				this.stream = stream;
			}
			
			public InputReader(String file){
				try {
					stream = new FileInputStream(file);
				} catch (FileNotFoundException e) {
					System.err.println(e);
				}
			}
			public InputReader() {
				this(System.in);
			}

			private int read() {
				if (numChars == -1)
					throw new InputMismatchException();
				if (curChar >= numChars) {
					curChar = 0;
					try {
						numChars = stream.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 nextString() {
				int c = read();
				while (isSpaceChar(c))
					c = read();
				StringBuilder res = new StringBuilder();
				do {
					res.appendCodePoint(c);
					c = read();
				} while (!isSpaceChar(c));
				return res.toString();
			}

			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;
			}

			private boolean isSpaceChar(int c) {
				return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
			}

			private boolean isEndOfLine(int c) {
				return c == '\n' || c == '\r' || c == -1;
			}
			
			public int[] nextArray(int N){
				int[] a = new int[N];
				for(int i=0; i<N; i++)
					a[i] = nextInt();
				return a;
			}
			//deneme
			public int[][] nextMatrix(int n, int m)
			{
				int[][] matrix = new int[n][m];
				for (int i = 0; i < n; i++) {
					for(int j=0; j<m; j++){
						matrix[i][j] = nextInt();
					}
				}
				return matrix;
			}

		}
}