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.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class _52C {

	public static void main(String[] args) throws IOException {
		FastScanner fs=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=fs.nextInt();
		int[] a=new int[n];
		for (int i=0; i<n; i++) a[i]=fs.nextInt();
		int nQueries=fs.nextInt();
		SegTree st=new SegTree(0, n-1, a);
		for (int qq=0; qq<nQueries; qq++) {
			String[] parts=fs.br.readLine().split(" ");
			int[] nums=new int[parts.length];
			for (int i=0; i<nums.length; i++) nums[i]=Integer.parseInt(parts[i]);
			if (parts.length==3) {
				if (nums[0]<=nums[1]) {
					st.update(nums[0], nums[1], nums[2]);
				}
				else {
					st.update(nums[0], n-1, nums[2]);
					st.update(0, nums[1], nums[2]);
				}
			}
			else {
				if (nums[0]<=nums[1]) {
					out.println(st.query(nums[0], nums[1]));
				}
				else {
					out.println(Math.min(st.query(nums[0], n-1), st.query(0, nums[1])));
				}
			}
		}
		out.close();
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
	
	static class SegTree {
		int leftmost, rightmost;
		SegTree lChild, rChild;
		long min;
		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);
				min=Math.min(lChild.min, rChild.min);
			}
			else min=a[leftmost];
		}
		
		public void recalc() {
			if (leftmost==rightmost) return;
			min=Math.min(lChild.min(), rChild.min());
		}
		
		public long min() {
			return min+toProp;
		}
		
		public void prop() {
			if (leftmost==rightmost) min+=toProp;
			else {
				lChild.toProp+=toProp;
				rChild.toProp+=toProp;
			}
			toProp=0;
			recalc();
		}
		
		public void update(int l, int r, long by) {
			if (l<=leftmost && r>=rightmost) {
				toProp+=by;
				return;
			}
			if (l>rightmost || r<leftmost) return;
			prop();
			lChild.update(l, r, by);
			rChild.update(l, r, by);
			recalc();
		}
		
		public long query(int l, int r) {
			if (l<=leftmost && r>=rightmost) return min();
			if (l>rightmost || r<leftmost) return Long.MAX_VALUE;
			prop();
			return Math.min(lChild.query(l, r), rChild.query(l, r));
		}
	}

}
