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.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.InputMismatchException;

public class C52 {

	static class Solver {

		class SegTree {

			int n;
			long oo = 123456789123456789L;
			long[] hi, lo, min, delta;

			SegTree(int nn) {
				n = nn;
				hi = new long[4 * n + 1];
				lo = new long[4 * n + 1];
				min = new long[4 * n + 1];
				delta = new long[4 * n + 1];

				init(1, 0, n - 1);

			}

			void init(int i, int a, int b) {

				lo[i] = a;
				hi[i] = b;

				if (a == b)
					return;

				int m = (a + b) / 2;
				init(2 * i, a, m);
				init(2 * i + 1, m + 1, b);
			}

			void inc(int a, int b, int val) {
				inc(1, a, b, val);
			}

			void prop(int i) {
				delta[2 * i] += delta[i];
				delta[2 * i + 1] += delta[i];
				delta[i] = 0;
			}

			void update(int i) {
				min[i] = Math.min(min[2 * i] + delta[2 * i], min[2 * i + 1] + delta[2 * i + 1]);
			}

			void inc(int i, int a, int b, int val) {
				// feeding down from parent i to range a-b
				if (b < lo[i] || hi[i] < a)
					return;
				if (a <= lo[i] && hi[i] <= b) {
					delta[i] += val;
					return;
				}

				prop(i);
				inc(2 * i, a, b, val);
				inc(2 * i + 1, a, b, val);
				update(i);
			}

			long min(int a, int b) {
				return min(1, a, b);
			}

			long min(int i, int a, int b) {
				if (b < lo[i] || hi[i] < a)
					return oo;

				if (a <= lo[i] && hi[i] <= b)
					return min[i] + delta[i];

				prop(i);

				long L = min(2 * i, a, b);
				long R = min(2 * i + 1, a, b);

				update(i);

				return Math.min(L, R);
			}

		}

		int N, M;
		SegTree S;

		long min(String[] dat) {
			int a = Integer.parseInt(dat[0]), b = Integer.parseInt(dat[1]);
			if (a <= b)
				return S.min(a, b);
			else
				return Math.min(S.min(0, b), S.min(a, N - 1));
		}

		void inc(String[] dat) {
			int a = Integer.parseInt(dat[0]), b = Integer.parseInt(dat[1]), v = Integer.parseInt(dat[2]);
			if (a <= b)
				S.inc(a, b, v);
			else {
				S.inc(0, b, v);
				S.inc(a, N - 1, v);
			}

		}

		public void solve(int testNumber, FastScanner s, PrintWriter out) {

			N = s.nextInt();
			S = new SegTree(N);
			for (int i = 0; i < N; i++) {
				S.inc(i, i, s.nextInt());
			}

			M = s.nextInt();

			for (int i = 0; i < M; i++) {
				String[] dat = s.nextLine().split("\\s+");
				if (dat.length == 2)
					out.println(min(dat));
				else
					inc(dat);
			}

		}

	}

	public static void main(String[] args) {

		FastScanner s = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Solver solver = new Solver();
		solver.solve(1, s, out);

		out.close();

	}

	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		public FastScanner(String s) {
			this.stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
		}

		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++];
		}

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

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

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

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

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

		public String next() {
			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 String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}

		// Jacob Garbage

		public int[] nextIntArray(int N) {
			int[] ret = new int[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextInt();
			return ret;
		}

		public long[] nextLongArray(int N) {
			long[] ret = new long[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextLong();
			return ret;
		}

		public int[][] next2DIntArray(int N, int M) {
			int[][] ret = new int[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextIntArray(M);
			return ret;
		}

		public double[] nextDoubleArray(int N) {
			double[] ret = new double[N];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDouble();
			return ret;
		}

		public double[][] next2DDoubleArray(int N, int M) {
			double[][] ret = new double[N][];
			for (int i = 0; i < N; i++)
				ret[i] = this.nextDoubleArray(M);
			return ret;
		}

	}

}
