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 Solution {
	InputReader in = new InputReader();
	PrintWriter out = new PrintWriter(System.out);

	void solve()
	{
		int n = in.nextInt();
		int[] arr = in.nextArray(n);
		int m = in.nextInt();
		SegmentTree st = new SegmentTree(arr);
		for (int m0 = 0; m0 < m; m0++) {
			String[] q = in.nextLine().split(" ");
			int l = Integer.parseInt(q[0]);
			int r = Integer.parseInt(q[1]);
			if (q.length == 3) {
				if (r < l) {
					st.update(l, n-1, Integer.parseInt(q[2]));
					st.update(0, r, Integer.parseInt(q[2]));
				}
				else {
					st.update(l, r, Integer.parseInt(q[2]));
				}
			}
			else {
				if (r < l) {
					out.println(Math.min(
							st.query(l, n-1), st.query(0, r)));
				}
				else {
					out.println(st.query(l, r));
				}
			}
		}
	}

	public class SegmentTree {
		private int n;
		private int[] tree;
		private int[] lazy;
		
		// ******************************************************************* //
		// 0-based indexing.
		// Currently: Query operation takes MIN of the given range.
		//            Update operation increases the given range by the value.		
		public final int DEFAULT_VALUE = Integer.MAX_VALUE;
		public final int DEFAULT_LAZY = 0;
		public int correctFunction(int a, int b) {
			return Math.min(a, b);
		}
		public void updateLazy(int i, int l, int r, int val) {
			lazy[i] += val;
			tree[i] += val;
		}
		// ******************************************************************* //
		
		public SegmentTree(int[] arr) {
			n = arr.length;
			int len = 1;
			while (len < arr.length) len *= 2;
			tree = new int[len * 2];
			lazy = new int[len * 2];
			for (int i = 0; i < lazy.length; i++) lazy[i] = DEFAULT_LAZY;
			build(1, 0, n-1, arr);
		}

		public void update(int ql, int qr, int val) {
			update(ql, qr, val, 1, 0, n-1);
		}

		public int query(int l, int r) {
			return query(l, r, 1, 0, n-1);
		}

		private void build(int i, int l, int r, int[] arr) {
			if (l == r) {
				tree[i] = arr[l];
				return;
			}
			int m = (l+r+1) / 2;
			build(2*i, l, m-1, arr);
			build(2*i + 1, m, r, arr);
			tree[i] = correctFunction(tree[2*i], tree[2*i + 1]);
		}

		private void update(int ql, int qr, int val, int i, int l, int r) {
			if (qr < l || ql > r) return;
			if (qr >= r && ql <= l) {
				updateLazy(i, l, r, val);
				return;
			}
			propagateLazy(i, l, r);
			int m = (l+r+1) / 2;
			update(ql, qr, val, 2*i, l, m-1);
			update(ql, qr, val, 2*i + 1, m, r);
			tree[i] = correctFunction(tree[2*i], tree[2*i + 1]);
		}

		private int query(int ql, int qr, int i, int l, int r) {
			if (qr < l || ql > r) return DEFAULT_VALUE;
			if (qr >= r && ql <= l) {
				return tree[i];
			}
			propagateLazy(i, l, r);
			int m = (l+r+1) / 2;
			return correctFunction(query(ql, qr, 2*i, l, m-1),
					query(ql, qr, 2*i + 1, m, r));
		}

		private void propagateLazy(int i, int l, int r) {
			int m = (l+r+1) / 2;
			updateLazy(2*i, l, m-1, lazy[i]);
			updateLazy(2*i + 1, m, r, lazy[i]);
			lazy[i] = DEFAULT_LAZY;
		}
	}

	public static void main(String[] args) throws Exception { Solution s = new Solution(); s.solve(); s.out.close(); }
	class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader() { this.stream = System.in; }

		public InputReader(String file) { 
			try {
				stream = new FileInputStream(file);
			} catch (FileNotFoundException e) {
				System.err.println(e);
			}
		}

		public int[] nextArray(int n)
		{
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public int[][] nextMatrix(int n, int m)
		{
			int[][] matrix = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					matrix[i][j] = nextInt();
				}
			}
			return matrix;
		}

		public String nextLine()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public double nextDouble()
		{
			return Double.parseDouble(nextString());
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		private int read()
		{
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
        //xd deneme
		private boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }

		private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
	}
}