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.*;
public class Main {
static int tree[];
static int lazy[];
static int array[];	
public static void main(String [] args)throws Exception{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(br.readLine());
	array = new int[n];
	tree = new int[4*n];
	lazy = new int[4*n];
	StringTokenizer st = new StringTokenizer(br.readLine());
	for(int i = 0;i < n;i++){
		array[i] = Integer.parseInt(st.nextToken());
	}
	buildtree(1,0,n - 1);
	StringBuilder sb = new StringBuilder();
	int m = Integer.parseInt(br.readLine());
	for(int i = 0;i < m;i++){
		st = new StringTokenizer(br.readLine());
		int l = Integer.parseInt(st.nextToken());
		int r = Integer.parseInt(st.nextToken());
		
		if(st.hasMoreTokens()){
			int v = Integer.parseInt(st.nextToken());
			if(l > r){
			updatetree(1,0, n - 1,l,n - 1,v);
			updatetree(1,0, n - 1,0,r,v);	
			}
			else updatetree(1,0, n - 1,l,r,v);
	}
		else {
		if(l > r){
		int t1 = querytree(1,0, n - 1,l,n - 1);
		int t2 = querytree(1,0, n - 1,0,r);	
		sb.append(Math.min(t1,t2));
		}
		else sb.append(querytree(1,0, n - 1,l,r));
		sb.append('\n'); 
	}
}
System.out.println(sb);
}
static void buildtree(int node,int start,int end){
	if(start > end)return;
	if(start == end){
		tree[node] = array[start];
		return;
	}
	buildtree(2*node,start,(start + end)/2);
	buildtree(2*node + 1,(start + end)/2 + 1,end);
	tree[node] = Math.min(tree[2*node],tree[2*node + 1]);
}
static void updatetree(int node,int start,int end,int i,int j,int val){
	if(lazy[node] != 0){
		tree[node] += lazy[node];
		if(start != end){
			lazy[2*node] += lazy[node];
			lazy[2*node + 1] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end || start > j || end < i)return;
	if(start >= i && end <= j){
		tree[node] += val;
		if(start != end){
		  lazy[2*node] += val;
		  lazy[2*node + 1] += val;
		}
		return;
	}
	updatetree(2*node,start,(start + end)/2,i,j,val);
	updatetree(2*node + 1,(start + end)/2 + 1,end,i,j,val);
	tree[node] = Math.min(tree[2*node],tree[2*node + 1]);
}
static int querytree(int node,int start,int end,int i,int j){
	if(start > end || start > j || end < i)return Integer.MAX_VALUE;
	if(lazy[node] != 0){
		tree[node] += lazy[node];
		if(start != end){
			lazy[2*node] += lazy[node];
			lazy[2*node + 1] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start >= i && end <= j)return tree[node];
	int q1 = querytree(2*node,start,(start + end)/2,i,j);
	int q2 = querytree(2*node + 1,(start + end)/2 + 1,end,i,j);
	return Math.min(q1,q2);
}
}