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


public class CircularRMQ {
	static int n;
	
	static long [] segment;
    static int[] array;
    static long[]lazy;
    
    public CircularRMQ(int n) {
        segment = new long[4*n];
        lazy = new long[4* n];
    }
    
    public static void build(int l, int r, int node)
	{
		if(l==r){
			lazy[node] = 0;
			segment[node] = array[l];
		}
		else {
			build(l, right(l+r), left(node)); 
			build(right(l+r) +1, r, left(node) + 1); 
			segment[node] = Math.min(segment[left(node)], segment[left(node)+1]);
			}
		}
    
	public static int left(int node){
		return node << 1;
	}
	public static int right(int node){
		return node >> 1;
	}
		
	public static void prepare(int i, int l, int r){
//		System.out.println("i: " + i +" l :"+l+" r: "+r);
		if(lazy[i] != 0){
		if(l!=r){
			lazy[left(i)] += lazy[i]; 
			lazy[left(i) +1 ] += lazy[i];
			segment[left(i)] +=lazy[i]; 
			segment[left(i) + 1] +=lazy[i];
			lazy[i]=0;
			}
		}
	}
	
	public static void update(int l, int r, int b, int e, int v, int node){
			if(b > r || e < l){
			return;
		}	
		if(b<=l && e>=r){
			lazy[node] +=v;
			prepare(node, l, r);
			segment[node]+=v;
			return;
		}
		prepare(node, l, r);
		update(l, right(l+r), b, e, v, left(node));
		update(right(l+r) + 1, r, b ,e, v, left(node) + 1);
		segment[node] = Math.min(segment[left(node)], segment[left(node)+1]);
	}
	public static long query(int l, int r, int b, int e, int node){
		if (b <= l && e >= r){
			prepare(node, l, r);
			return segment[node];
		}
		else if (b > r || e < l){
			return Long.MAX_VALUE;
		}
		else{
			prepare(node, l, r);
			return Math.min(query(l,right(l+r), b, e , left(node)), query(right(l+r) + 1, r, b, e, left(node) +1));
		}
	}
	
	public static void main(String[]args) throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		n= Integer.parseInt(bf.readLine());
		StringTokenizer st = new StringTokenizer(bf.readLine());
		array=new int[n];
		new CircularRMQ(n);
		for(int i =0;i<n;i++){
			array[i]=Integer.parseInt(st.nextToken());
		}
		build(0,n-1,1);
		int m =Integer.parseInt(bf.readLine());
		for(int t=0;t<m;t++){
			st = new StringTokenizer(bf.readLine());
			if(st.countTokens()==2){
				int lf = Integer.parseInt(st.nextToken());
				int rg = Integer.parseInt(st.nextToken());
				if(lf>rg)
				System.out.println(Math.min(query(0,n-1,lf,n-1,1),query(0,n-1,0,rg,1)));
				else
				System.out.println(query(0,n-1,lf,rg,1));
			}
			else{
				int lf = Integer.parseInt(st.nextToken());
				int rg = Integer.parseInt(st.nextToken());
				int v= Integer.parseInt(st.nextToken());
				if(lf>rg){	
					update(0,n-1,lf,n-1,v,1);
					update(0,n-1,0,rg,v,1);
				}
				else 
					update(0,n-1,lf,rg,v,1);
				}
		}

	}
	
}
