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

public class CircularRMQ {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		int n = Integer.parseInt(in.readLine());
		Node segtree = new Node(0, n - 1);
		String line = in.readLine();
		StringTokenizer helper = new StringTokenizer(line);
		for (int i = 0; i < n; i++)
			segtree.add(i, i, Long.parseLong(helper.nextToken()));

		int m = Integer.parseInt(in.readLine());
		for (int i = 0; i < m; i++){
			line = in.readLine();
			String[] arr = line.split(" ");
			if (arr.length == 2) {
				long l = Long.parseLong(arr[0]);
				long r = Long.parseLong(arr[1]);
				long ans = 0;
				if (l <= r)
					ans = segtree.query(l, r);
				else
					ans = Math.min(segtree.query(l, n - 1), segtree.query(0, r));
				out.println(ans);
			}
			else {
				long l = Long.parseLong(arr[0]);
				long r = Long.parseLong(arr[1]);
				long v = Long.parseLong(arr[2]);
				if (l <= r)
					segtree.add(l, r, v);
				else {
					segtree.add(l, n - 1, v);
					segtree.add(0, r, v);
				}
			}
		}

		in.close();
		out.close();
	}

	static class Node {
		long min;
		long prop;
		long sum;
		long l, r;
		Node left, right;

		public Node(long le, long ri) { // inclusive, inclusive
			l = le;
			r = ri;
			min = 0;
			prop = 0;
			if (le == ri)
				return; // We have reached leaf node
			long mid = (l + r) / 2;
			left = new Node(le, mid);
			right = new Node(mid + 1, ri);
		}

		public void prop() {
			if (prop == 0 || left == null)
				return;
			left.add(l, r, prop);
			right.add(l, r, prop);
			prop = 0;
		}

		public void add(long le, long ri, long n) {
			if (le > r || ri < l)
				return; // outside of range
			if (le <= l && ri >= r) { // inside of range
				min += n;
				prop += n;
				sum += (r - l) * n;
				return;
			}
			prop();
			left.add(le, ri, n);
			right.add(le, ri, n);
			sum = left.sum + right.sum;
			min = Math.min(left.min, right.min);
		}

		public long query(long le, long ri) {
			if (le > r || ri < l)
				return Long.MAX_VALUE; // outside of range
			if (le <= l && ri >= r)
				return min; // inside range
			prop();
			return Math.min(left.query(le, ri), right.query(le, ri));
		}

		public long sum(long le, long ri) {
			if (le > r || ri < l)
				return 0; // outside of range
			if (le <= l && ri >= r)
				return sum; // inside range
			prop();
			return left.sum(le, ri) + right.sum(le, ri);
		}
	}

}
