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.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class CF52C {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int N = 1;
		while(N < n)
			N<<=1;
		long[]arr = new long[N+1];
		for (int i = 1; i <= n; i++) {
			arr[i] = 1l*sc.nextInt();
		}
		SegmentTree st = new SegmentTree(arr);
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			StringTokenizer st2 = new StringTokenizer(sc.nextLine());
			int from = Integer.parseInt(st2.nextToken())+1;
			int to = Integer.parseInt(st2.nextToken())+1;		
			if(st2.hasMoreTokens()){
				int val = Integer.parseInt(st2.nextToken());
				if(to < from){
					st.update_range(1, to, val);
					st.update_range(from, n, val);
				}else
					st.update_range(from, to, val);
		
			}else{
				if(to < from)
					pw.println(Math.min(st.query(1, to), st.query(from, n)));
				else
					pw.println(st.query(from, to));
			}
		}
		pw.flush();
		pw.close();
	}
	
	static class SegmentTree{
		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		long[] array, sTree, lazy;
		
		public SegmentTree(long[] in) {
			array = in;
			N = in.length - 1;
			sTree = new long[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new long[N << 1];
			build(1, 1, N);
		}
		
		void build(int node, int start, int end) // O(n)
		{
			if (start == end)
				sTree[node] = array[start];
			else {
				int mid = start + end >> 1; 
				build(node << 1, start, mid);
				build(node << 1 | 1, mid + 1, end); // node * 2 + 1
				sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);
			}
		}
		
		void update_point(int index, int val) // O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = Math.min(sTree[index << 1], sTree[index << 1 | 1]);
			}
		}
	
		void update_range(int i, int j, int val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}
		
		// i & j are the range needed but b & e are the nodes borders
		void update_range(int node, int start, int end, int i, int j, int val) {	
			if (i > end || j < start)
				return;
			if (start >= i && end <= j) {
				// (+= val) not (+= (end - start + 1) * val) because it is minimum
				sTree[node] += val;
				lazy[node] += val;
			} else {
				int mid = start + end >> 1;
				propagate(node, start, mid, end);
				update_range(node << 1, start, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, end, i, j, val);
				sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);
			}
		}
		
		void propagate(int node, int start, int mid, int end) {
			// update in children only
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			sTree[node << 1] += lazy[node];
			sTree[node << 1 | 1] += lazy[node];
			lazy[node] = 0;
		}
		
		long query(int i, int j) {
			return query(1, 1, N, i, j);
		}

		long query(int node, int start, int end, int i, int j) // O(log n)
		{
			if (i > end || j < start)
				return (long)1e13;
			if (start >= i && end <= j)
				return sTree[node];
			int mid = start + end >> 1;
			propagate(node, start, mid, end);
			long q1 = query(node << 1, start, mid, i, j);
			long q2 = query(node << 1 | 1, mid + 1, end, i, j);
			return Math.min(q1, q2);
		}
		
	}	
	
	static class FastScanner {
		StringTokenizer st;
		BufferedReader br;

		public FastScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public FastScanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}
