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 CF_52_C_CIRCULAR_RMQ {

	static final long INF = (long) 1e18;

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		long[] a = new long[n + 1];
		
		
		for (int i = 1; i <= n; i++)
			a[i] = sc.nextLong();
		
		SegmentTree st = new SegmentTree(a);

		int q = sc.nextInt();
		StringBuilder str = new StringBuilder();

		while (q--> 0) {
			String [] s = sc.nextLine().split(" ");
			int l = Integer.parseInt(s[0]) + 1;
			int r = Integer.parseInt(s[1]) + 1;
			
			if (s.length == 2) {
				if (l > r) {
					long q1 = st.query(l, n);
					long q2 = st.query(1, r);

					str.append(Math.min(q1, q2)).append("\n");

				} else {
					str.append(st.query(l, r)).append("\n");
				}

			} else {
				long val = Long.parseLong(s[2]);
				if (l > r) {
					st.update(l, n, val);
					st.update(1, r, val);
				} else
					st.update(l, r, val);
			}
		}

		System.out.print(str);

	}

	static class SegmentTree {
		long[] lazy, array, sTree;
		int n;

		SegmentTree(long[] in) {
			n = 1;

			while (n < in.length - 1)
				n <<= 1;

			array = new long[n + 1];
			Arrays.fill(array, INF);

			for (int i = 1; i < in.length; i++)
				array[i] = in[i];

			lazy = new long[n << 1];

			sTree = new long[n << 1];

			Arrays.fill(sTree, INF);

			build(1, 1, n);
		}

		void build(int node, int l, int r) {
			if (l == r) {
				sTree[node] = array[l];
				return;
			}

			int mid = (l + r) >> 1;

			build(node << 1, l, mid);
			build(node << 1 | 1, mid + 1, r);

			sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);

		}

		void update(int i, int j, long val) {
			updateRange(1, 1, n, i, j, val);
		}

		void updateRange(int node, int b, int e, int i, int j, long val) {
			if (b > j || e < i)
				return;

			if (i <= b && e <= j) {
				sTree[node] += val;
				lazy[node] += val;
				return;
			}

			propagate(node);

			int mid = (b + e) >> 1;
			updateRange(node << 1, b, mid, i, j, val);
			updateRange(node << 1 | 1, mid + 1, e, i, j, val);
			sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);

		}

		void propagate(int node) {
			sTree[node << 1] += lazy[node];
			sTree[node << 1 | 1] += lazy[node];
			lazy[node << 1] += lazy[node];
			lazy[node << 1 | 1] += lazy[node];

			lazy[node] = 0;

		}

		long query(int i, int j) {
			return query(1, 1, n, i, j);

		}

		long query(int node, int b, int e, int i, int j) {
			if (b > j || e < i)
				return INF;

			if (i <= b && e <= j)
				return sTree[node];

			propagate(node);

			int mid = (b + e) >> 1;

			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 double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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

	}

}
