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.*;
import java.util.*;

public class segTree {
	static final long INF = (long) 1e14;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int size = 1;
		while (size < n)
			size <<= 1;
		long[] arr = new long[size + 1];
		for (int i = 0; i <= size; i++)
			arr[i] = INF;
		for (int i = 1; i <= n; i++)
			arr[i] = sc.nextLong();
		SegmentTree t = new SegmentTree(arr);
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			StringTokenizer st = new StringTokenizer(sc.nextLine());
			int l = Integer.parseInt(st.nextToken()) + 1;
			int r = Integer.parseInt(st.nextToken()) + 1;
			if (st.hasMoreTokens()) {
				int val = Integer.parseInt(st.nextToken());
				if (l <= r)
					t.inc(1, 1, size, l, r, val);
				else {
					t.inc(1, 1, size, 1, r, val);
					t.inc(1, 1, size, l, size, val);
				}
			} else {
				long ans;
				if (l <= r)
					ans = t.query(1, 1, size, l, r);
				else
					ans = Math.min(t.query(1, 1, size, 1, r), t.query(1, 1, size, l, size));
				out.println(ans);
			}
		}
		out.close();
	}

	static class SegmentTree {
		long segT[], arr[], lazy[];
		int n;

		public SegmentTree(long[] arr) {
			this.arr = arr;
			n = arr.length - 1;
			segT = new long[2 * n];
			lazy = new long[2 * n];
			build(1, 1, n);
		}

		public void build(int node, int l, int r) {
			if (l == r)
				segT[node] = arr[l];
			else {
				int mid = l + r >> 1;
				build(node << 1, l, mid);
				build((node << 1) + 1, mid + 1, r);
				segT[node] = Math.min(segT[node << 1], segT[(node << 1) + 1]);
			}
		}

		public void inc(int node, int b, int e, int i, int j, int val) {
			if (e < i || j < b) // no overlap
				return;
			if (b >= i && e <= j) { // cur interval is contained in original interval
				segT[node] += val;
				lazy[node] += val;
			} else {
				int mid = b + e >> 1;
				propagate(node);
				inc(node << 1, b, mid, i, j, val);
				inc(node << 1 | 1, mid + 1, e, i, j, val);
				segT[node] = Math.min(segT[node << 1], segT[node << 1 | 1]);
			}
		}

		public void propagate(int node) {
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];
			segT[node << 1] += lazy[node];
			segT[node << 1 | 1] += lazy[node];
			lazy[node] = 0;
		}

		public long query(int node, int b, int e, int i, int j) {
			if (i > e || j < b)
				return INF;
			if (b >= i && e <= j)
				return segT[node];
			int mid = b + e >> 1;
			propagate(node);
			return Math.min(query(node << 1, b, mid, i, j), query(node << 1 | 1, mid + 1, e, i, j));
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}
