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
//package Jobeel;
import java.util.*;
import java.io.*;
 
public class codeforces2 {
	
	public static void main(String[] args) throws IOException {
        PrintWriter pw=new PrintWriter(System.out);
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
	    long [] arr=new long [x+1];
	    for(int i=1;i<=x;i++) arr[i]=sc.nextLong();
	    segMentTree t1=new segMentTree(arr);
	    int t=sc.nextInt();
	    while(t-->0) {
	    	String [] st=sc.nextLine().split(" ");
	   
	    	if(st.length==2) pw.println(t1.circle(Integer.parseInt(st[0])+1,Integer.parseInt(st[1])+1));
	    	else t1.upload_range(Integer.parseInt(st[0])+1,Integer.parseInt(st[1])+1,Integer.parseInt(st[2]));
	   // pw.println(t1);
	    }
		pw.flush(); 
		pw.close();
	}
	static class segMentTree{
   	 int N;
   	 long [] array,sTree,lazy;
   	 public segMentTree(long [] a) {
   		 array=a; N=a.length-1;
   		 sTree =new long [N<<2];
   		 lazy =new long [N<<2];
   		 build(1, 1, N);
   	 }
   	 public void build(int Node,int b,int e) {
   		 if(e==b) sTree[Node]=array[b];
   		 else {
				int mid=b+e>>1;
   		    build(Node<<1, b, mid);
   		    build(Node<<1|1, mid+1, e);
   		    sTree[Node]=Math.min(sTree[Node<<1],sTree[Node<<1|1]);
			}
   	 }
   	 public void upload_range(int b,int e,long value) {
   		 if(b>e) {
   			 uplaod_range(1, 1,N, b, N, value);
   			 uplaod_range(1, 1,N, 1, e, value);
   			 
   		 }else  uplaod_range(1, 1,N, b, e, value);
   		
   	 }
   	 public void uplaod_range(int Node,int b,int e,int i,int j,long value) {
   		 if(b>j || i>e) return;
   		 if(b>=i && e<=j) {
   			 sTree[Node]+=value;
   			 lazy[Node]+=value;
   		 }else {
				int mid=e+b>>1;
   		    propagate(Node, b, mid, e);
   		    uplaod_range(Node<<1,b,mid, i, j, value);
   		    uplaod_range(Node<<1|1, mid+1, e, i, j, value);
   		    sTree[Node]=Math.min(sTree[Node<<1],sTree[Node<<1|1]);
			}
   	 }
   	 public void propagate(int Node,int b,int mid,int e) {
   		 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;
   	 }
   	 public long circle(int b,int e) {
   		 if(b>e) return Math.min(circle(1, 1, N, b, N),circle(1, 1, N, 1, e));
   		 else
   		 return circle(1, 1, N, b, e);
   	 }
   	 public long circle(int Node,int b,int e,int i,int j) {
   		 if(i>e || j<b) return (long)2e18;
   		 if(b>=i && e<=j) return sTree[Node];
   		 else {
				int mid=e+b>>1;
   	        	propagate(Node, b, mid, e);
   	        	long ans1=circle(Node<<1, b, mid, i, j);
   	        	long ans2=circle(Node<<1|1, mid+1, e, i, j);
   		   return Math.min(ans1 ,ans2 );
			  }
   	 }
   	 public String toString() {return Arrays.toString(sTree);}
     }
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}
 
		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}
 
		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();
		}
 
	}
 
}