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;

public class c_testinground1 {
	static long[] arr, m, lazy;

	public static void initialize(int node, int b, int e) {
		if (b == e) {
			m[node] = arr[b];
			return;
		}
		initialize(node * 2 + 1, b, (b + e) / 2);
		initialize(node * 2 + 2, (b + e) / 2 + 1, e);
		m[node] = Math.min(m[node * 2 + 1], m[node * 2 + 2]);
	}

	public static void update(int node, int b, int e, int i, int j, long val) {
		if (lazy[node] != 0) {
			m[node] += lazy[node];
			if (b != e) {
				lazy[node * 2 + 1] += lazy[node];
				lazy[node * 2 + 2] += lazy[node];
			}
			lazy[node] = 0;
		}
		if (b > e || b > j || e < i)
			return;
		if (b >= i && e <= j) {
			m[node] += val;
			if (b != e) {
				lazy[node * 2 + 1] += val;
				lazy[node * 2 + 2] += val;
			}
			return;
		}
		update(node * 2 + 1, b, (b + e) / 2, i, j, val);
		update(node * 2 + 2, (b + e) / 2 + 1, e, i, j, val);
		m[node] = Math.min(m[node * 2 + 1], m[node * 2 + 2]);
	}

	public static long query(int node, int b, int e, int i, int j) {
		if (b > e || e < i || b > j)
			return Integer.MAX_VALUE;
		if (lazy[node] != 0) {
			m[node] += lazy[node];
			if (b != e) {
				lazy[node * 2 + 1] += lazy[node];
				lazy[node * 2 + 2] += lazy[node];
			}
			lazy[node] = 0;
		}
		if (b >= i && e <= j)
			return m[node];
		long p1 = query(node * 2 + 1, b, (b + e) / 2, i, j);
		long p2 = query(node * 2 + 2, (b + e) / 2 + 1, e, i, j);
		return Math.min(p1, p2);
	}

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(in.readLine());
		arr = new long[n];
		int len = (int) (2 * Math.pow(2, Math.log10(n) / Math.log10(2) + 1));
		lazy = new long[len];
		m = new long[len];
		String[] s = in.readLine().split(" ");
		for (int i = 0; i < s.length; i++)
			arr[i] = Integer.parseInt(s[i]);

		initialize(0, 0, n - 1);
		int mm = Integer.parseInt(in.readLine());
		for (int i = 0; i < mm; i++) {
			s = in.readLine().split(" ");
			if (s.length == 2) {
				int beg = Integer.parseInt(s[0]);
				int end = Integer.parseInt(s[1]);
				if (beg > end) {
					long p1 = query(0, 0, n - 1, beg, n - 1);
					p1 = Math.min(p1, query(0, 0, n-1, 0, end));
					System.out.println(p1);
				} else
					System.out.println(query(0, 0, n - 1, beg, end));

			} else {
				int beg = Integer.parseInt(s[0]);
				int end = Integer.parseInt(s[1]);
				long val = Long.parseLong(s[2]);
				if (beg > end) {
					update(0, 0, n - 1, beg, n - 1, val);
					update(0, 0, n - 1, 0, end, val);
				} else{
					update(0, 0, n - 1, beg, end, val);
				}
			}
		}
	}
}
