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 CircularRMQ {
	class SegmentTree {
		int n;
		long[] delta, lo, hi, min;
		public SegmentTree(int n) {
			this.n = n;
			delta = new long[4*n+1];
			min = new long[4*n+1];
			lo = new long[4*n+1];
			hi = new long[4*n+1];
			init(1, 0, n-1);
		}
		void construct(long[] arr, int i, int a, int b) {
			if(a == b) {
				min[i] = arr[a];
				return;
			}
			int m = (a+b)/2;
			construct(arr, 2*i, a, m);
			construct(arr, 2*i+1, m+1, b);
			update(i);
		}
		void increment(int a, int b, long v) {
			increment(1, a, b, v);
		}
		long minimum(int a, int b) {
			return minimum(1, a, b);
		}
		void init(int i, long a, long b) {
			lo[i] = a;
			hi[i] = b;
			if(a == b)
				return;
			long m = (a+b)/2;
			init(2*i, a, m);
			init(2*i+1, m+1, b);
		}
		void prop(int i) {
			delta[2*i]+=delta[i];
			delta[2*i+1]+=delta[i];
			delta[i] = 0;
		}
		void update(int i) {
			min[i] = Math.min(min[2*i]+delta[2*i], min[2*i+1]+delta[2*i+1]);
		}
		private void increment(int i, int a, int b, long v) {
			if(b < lo[i] || a > hi[i])
				return;
			if(a <= lo[i] && b >= hi[i]) {
				delta[i]+=v;
				return;
			}
			prop(i);
			increment(2*i, a, b, v);
			increment(2*i+1, a, b, v);
			update(i);
		}
		private long minimum(int i, int a, int b) {
			if(b < lo[i] || a > hi[i])
				return Long.MAX_VALUE;
			if(a <= lo[i] && b >= hi[i])
				return min[i] + delta[i];
			prop(i);
			long minLeft = minimum(2*i, a, b);
			long minRight = minimum(2*i+1, a, b);
			update(i);
			return Math.min(minLeft, minRight);
		}
	}
	public CircularRMQ(Scanner scan, BufferedReader br, PrintWriter out) throws Exception {
		int n = Integer.parseInt(br.readLine());
		SegmentTree tree = new SegmentTree(n);
		long[] arr = new long[n];
		String[] in = br.readLine().split("\\s+");
		for(int i = 0 ; i < n ; i++)
			arr[i] = Long.parseLong(in[i]);
		tree.construct(arr, 1, 0, n-1);
		int q = Integer.parseInt(br.readLine());
		for(int i = 0 ; i < q ; i++) {
			String[] query = br.readLine().split("\\s+");
			int a = Integer.parseInt(query[0]), b = Integer.parseInt(query[1]);
			if(query.length == 3) { // Update Range Query
				long value = Long.parseLong(query[2]);
				if(b < a) {
					tree.increment(0, b, value);
					tree.increment(a, n-1, value);
				} else {
					tree.increment(a, b, value);
				}
			} else { // Range Minimum Query
				if(b < a) {
					out.println(Math.min(tree.minimum(0, b), tree.minimum(a, n-1)));
				} else {
					out.println(tree.minimum(a, b));
				}
			}
		}
	}
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new CircularRMQ(scan, br, out);
		out.close();
	}
}
