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

	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

		int n = in.nextInt();
		SegmentTree tree = new SegmentTree(n);
		for (int i = 0; i < n; i++) {
			tree.increment(i, i, in.nextInt());
		}
		
		int m = in.nextInt();
		while (m-- > 0) {
			String[] line = in.nextLine().split(" ");
			if (line.length == 2) {
				int l = Integer.parseInt(line[0]), r = Integer.parseInt(line[1]);
				if (l <= r) {
					out.println(tree.minimum(l, r));
				}
				else {
					out.println(Math.min(tree.minimum(0, r), tree.minimum(l, n-1)));
				}
			}
			else {
				int l = Integer.parseInt(line[0]), r = Integer.parseInt(line[1]), v = Integer.parseInt(line[2]);
				if (l <= r) {
					tree.increment(l, r, v);
				}
				else {
					tree.increment(0, r, v);
					tree.increment(l, n-1, v);
				}
			}
		}

		out.close();
	}
	

	static class SegmentTree {
		int n;
		int[] lo, hi, min, delta;
		
		public SegmentTree(int n) {
			this.n = n;
			lo = new int[4*n+1];
			hi = new int[4*n+1];
			min = new int[4*n+1];
			delta = new int[4*n+1];
			
			init(1, 0, n-1);
		}
		
		public void increment(int a, int b, int val) {
			increment(1, a, b, val);
		}
		
		public int minimum(int a, int b) {
			return minimum(1, a, b);
		}
		
		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 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 increment(int i, int a, int b, int val) {
			if (b < lo[i] || hi[i] < a) 
				return;
			
			if (a <= lo[i] && hi[i] <= b) {
				delta[i] += val;
				return;
			}
			
			prop(i);
			
			increment(2*i, a, b, val);
			increment(2*i+1, a, b, val);
			
			update(i);
		}
		
		int minimum(int i, int a, int b) {
			if (b < lo[i] || hi[i] < a) 
				return Integer.MAX_VALUE;
			
			if (a <= lo[i] && hi[i] <= b) {
				return min[i] + delta[i];
			}
			
			prop(i);
			
			int minLeft = minimum(2*i, a, b);
			int minRight = minimum(2*i+1, a, b);
			
			update(i);
			
			return Math.min(minLeft, minRight);
		}
	}


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

		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();
		}
	}
}
