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.Arrays;
import java.util.StringTokenizer;


public class CircularRMQ {
	long[] a, segmentTree, lazy;
	int N;
	public CircularRMQ(long[] a) {
		this.a=a;
		N=a.length-1;
		segmentTree= new long[2*N];
		lazy= new long[2*N];
		build(1,1,N);
	}
	public void build(int indx, int l, int r)
	{
		if(l==r){segmentTree[indx]=a[l];return;}
		int mid=l+r>>1;
		int leftChild=indx<<1;
		int rightChild=indx<<1|1;
		build(leftChild,l,mid);
		build(rightChild, mid+1, r);
		segmentTree[indx]=Math.min(segmentTree[leftChild],segmentTree[rightChild]);	
	}
	public long query(int i,int j)
	{
		return query(1, 1, N, i, j);
	}
	public long query(int indx, int l, int r, int i, int j)
	{
		if(r<i || j<l) return Long.MAX_VALUE;
		if(i<=l && r<=j)return segmentTree[indx];
		int mid=l+r>>1;
		int leftChild=indx<<1;
		int rightChild=indx<<1|1;
		propagate(indx);
		return Math.min(query(leftChild, l, mid, i, j) , query(rightChild, mid+1, r, i, j));
	}
	
	public void updateRange(int i, int j, int val)
	{
		updateRange(1, 1, N, i, j, val);
	}
	public void updateRange(int indx, int l, int r, int i, int j, int val)
	{
		if(r<i || j<l) return;
		if(i<=l && r<=j){segmentTree[indx]+=val;lazy[indx]+=val;return;};
		int mid=l+r>>1;
		int leftChild=indx<<1;
		int rightChild=indx<<1|1;
		propagate(indx);
		updateRange(leftChild, l, mid, i, j, val);
		updateRange(rightChild, mid + 1, r, i, j, val);
		segmentTree[indx]=Math.min(segmentTree[leftChild] , segmentTree[rightChild]);
	}
	public void propagate(int indx)
	{
		segmentTree[indx<<1]+=lazy[indx];
		segmentTree[indx<<1|1]+=lazy[indx];
		lazy[indx<<1]+=lazy[indx];
		lazy[indx<<1|1]+=lazy[indx];
		lazy[indx]=0;
	}
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N=1;
		while(N<n)
		{
			N*=2;
		}
		long[] a = new long[N+1];
		for (int i = 1; i <= n; i++) {
			a[i]= Integer.parseInt(st.nextToken());
		}
		for (int i = n+1; i < a.length; i++) {
			a[i]=Long.MAX_VALUE;
		}
		int m = Integer.parseInt(br.readLine());
		CircularRMQ segmentTree = new CircularRMQ(a);
		for (int i = 0; i < m; i++) {
			st = new StringTokenizer(br.readLine());
			if(st.countTokens()==3)
			{
				int lf = Integer.parseInt(st.nextToken())+1;
				int rf = Integer.parseInt(st.nextToken())+1;
				int val = Integer.parseInt(st.nextToken());
				if(lf>rf)
				{
					segmentTree.updateRange(lf, n, val);
					segmentTree.updateRange(0, rf, val);
				}
				else
				{
					segmentTree.updateRange(lf, rf, val);
				}
			}
			else
			{
				int lf = Integer.parseInt(st.nextToken())+1;
				int rf = Integer.parseInt(st.nextToken())+1;
				if(lf>rf)
				{
				
					pw.println(Math.min(segmentTree.query(lf, n), segmentTree.query(0, rf)));
				}
				else
				{
					pw.println(segmentTree.query(lf, rf));
				}
			}
		}
		pw.close();
	}
}
