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

public class CircularRMQ {

	final static long INF = (long)1e18;
	public static void main(String[] args) throws NumberFormatException, IOException {
		 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

		int n = Integer.parseInt(br.readLine());
		int N = 1; 
		while(N < n) 
			N <<= 1;
		long [] seq = new long[N+1];
		StringTokenizer tk = new StringTokenizer(br.readLine());
		
		for (int i = 1; i <= N; i++) 
			if(tk.hasMoreTokens())
				seq[i] = Long.parseLong(tk.nextToken());
			else
				seq[i] = INF;
		
		seq[0] = INF;
		
		SegmentTree st = new SegmentTree(seq);
		int m = Integer.parseInt(br.readLine());
		while(m-->0)
		{
			tk = new StringTokenizer(br.readLine());
			int lf = Integer.parseInt(tk.nextToken())+1;
			int rg = Integer.parseInt(tk.nextToken())+1;
			
			int value = (int)INF;
			boolean inc = false;
			if(tk.hasMoreTokens())
			{
				value = Integer.parseInt(tk.nextToken());
				inc = true;
			}
			if(inc)
			{
				if(lf>rg)
				{
					st.update_range(lf, n, value);
					st.update_range(1, rg, value);
				}
				else
					st.update_range(lf, rg, value);
			}
			else
			{
				if(lf>rg)
					out.println(Math.min(st.query(lf,n),st.query(1, rg)));
				else
					out.println(st.query(lf,rg));
			}
			
		}
		out.flush();
		out.close();

	}
		 


	static class SegmentTree{
		int N; 			//the number of elements in the array as a power of 2 (i.e. after padding)
		long[] array, sTree, lazy;
		
		SegmentTree(long[] in)		
		{
			array = in; 
			N = in.length - 1;
			sTree = new long[N<<1];		//no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new long[N<<1];
			build(1,1,N);
		}
		
		void build(int node, int b, int e)	// O(n)
		{
			if(b == e)					
				sTree[node] = array[b];
			else						
			{
				build(node<<1,b,(b+e)/2);
				build((node<<1)+1,(b+e)/2+1,e);
				sTree[node] = Math.min(sTree[node<<1],sTree[(node<<1)+1]);
			}
		}
		
		
		void update_point(int index, int val)			// O(log n)
		{
			index += N - 1;				
			sTree[index] += val;			
			while(index>1)				
			{
				index >>= 1;
				sTree[index] = Math.min(sTree[index<<1],sTree[(index<<1) + 1]);		
			}
		}
		
		
		void update_range(int i, int j, int val)		// O(log n) 
		{
			update_range(1,1,N,i,j,val);
		}
		
		void update_range(int node, int b, int e, int i, int j, int val)
		{
			if(i > e || j < b)		
				return;
			if(b >= i && e <= j)		
			{
				sTree[node] += val;			
				lazy[node] += val;				
			}							
			else		
			{
				propagate(node, b, e);
				update_range(node<<1,b,(b+e)/2,i,j,val);
				update_range((node<<1)+1,(b+e)/2+1,e,i,j,val);
				sTree[node] = Math.min(sTree[node<<1],sTree[(node<<1)+1]);		
			}
			
		}
		void propagate(int node, int b, 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;
		}
		
		long query(int i, int j)
		{
			return query(1,1,N,i,j);
		}
		
		long query(int node, int b, int e, int i, int j)	// O(log n)
		{
			if(i>e || j <b)
				return INF;		
			if(b>= i && e <= j)
				return sTree[node];
			propagate(node, b, e);
			long q1 = query(node<<1,b,(b+e)/2,i,j);
			long q2 = query((node<<1)+1,(b+e)/2+1,e,i,j);
			return Math.min(q1,q2);	
					
		}	
	}

}