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.ArrayList;
import java.util.List;
import java.util.Scanner;


// matt fontaine

public class MaxFlow {
	
	
	static int[] low = new int[200000 * 4 + 1];
	static int[] high = new int[200000 * 4 + 1];
	static int[] min = new int[  200000 * 4 + 1];
	static int[] delta = new int[ 200000 * 4 + 1];

	public static void main(String[] args) throws IOException {
		
		//Scanner in = new Scanner(System.in);
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		PrintWriter out = new PrintWriter(System.out);
		
		
		int n = (Integer.parseInt(in.readLine()));
		
		String[] line = in.readLine().split("\\s+");
		
		init(1, 0, n-1);

		for(int i=0; i<n; i++) {
			increment(i, i, Integer.parseInt(line[i]));
		}
		
		int q = Integer.parseInt(in.readLine());
		
		for(int i=0; i<q; i++) {
			line = in.readLine().split("\\s+");
			
			if(line.length == 2) {
				int l = Integer.parseInt(line[0]);
				int r = Integer.parseInt(line[1]);
				
				if( l  > r) {
					int res = min(l, n-1);
					int res2 = min(0, r);
					
					out.println(Math.min(res, res2));
				}
				else {
					out.println(min(l, r));
				}
			}
			else {
				
				int l = Integer.parseInt(line[0]);
				int r = Integer.parseInt(line[1]);
				int am = Integer.parseInt(line[2]);
				
				if( l  > r) {
					 increment(l, n-1, am);
					 increment(0, r, am);
				}
				else {
					increment(l, r, am);
				}
			}
		}
		
		
		out.close();
		
	}
	
	
	static void prop(int i) {
		delta[2*i] += delta[i];
		delta[2*i +1] += delta[i];
		
		delta[i] = 0;
	}
	
	static void update(int i) {
		min[i] = Math.min(min[2*i+1] + delta[2*i+1] , min[2*i] + delta[2*i] );
	}
	
	
	static void increment(int l, int r, int amount) {
		inc(1, l, r, amount);
	}
	
	
	private static void inc(int i, int l, int r, int amount) {
		
		if(low[i] > r || high[i] < l) {
			return;
		}
		else if(low[i] >= l && high[i] <= r) {
			delta[i] += amount;
			return;
		}
				
		prop(i);
		
		inc(2 * i, l, r, amount);
		inc(2 * i+1 , l, r, amount);
		
		update(i);
		
	}


	static int min(int l, int r) {
		return min(1, l, r);
	}
	
	private static int min(int i, int l, int r) {
		
		if(low[i] > r || high[i] < l) {
			return Integer.MAX_VALUE;
		}
		else if(low[i] >= l && high[i] <= r) {
			return min[i] + delta[i];
		}
		
		prop(i);
		
		
		int minL = min(2*i, l, r);
		int mindR = min(2*i + 1, l, r);
		
		update(i);
		
		return Math.min(minL, mindR);
	}


	// index in array      and interval ir covers
	static void init(int index, int l, int r) {
		low[index] = l;
		high[index] = r;
		
		if(l == r) {
			return;
		}
		
		int mid = (l + r)/2;
		
		init(2 * index, l, mid);
		init(2 * index +1, mid+1, r);
	}
	
}
