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

public class C_52 {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int N = 1;
		while(N < n)
			N <<= 1;
		long[] array = new long[N + 1];
		Arrays.fill(array, Long.MAX_VALUE);
		for(int i = 1; i <= n; i++)
			array[i] = sc.nextLong();
		SegmentTree tree = new SegmentTree(array);
		
		int m = sc.nextInt();
		while(m-->0) {
			StringTokenizer st = new StringTokenizer(sc.nextLine());
			if(st.countTokens() == 2) {
				int x = Integer.parseInt(st.nextToken()) + 1, y = Integer.parseInt(st.nextToken()) + 1;
				if(x > y)
					pw.println(Math.min(tree.query(x, n), tree.query(1, y)));
				else
					pw.println(tree.query(x, y));
			} else {
				int x = Integer.parseInt(st.nextToken()) + 1, y = Integer.parseInt(st.nextToken()) + 1;
				int v = Integer.parseInt(st.nextToken());
				if(x > y) {
					tree.update_range(x, n, v);
					tree.update_range(1, y, v);
				} else
					tree.update_range(x, y, v);
			}
		}
		
		pw.flush();
	}
	
	public static class SegmentTree {
		
		long INF = Long.MAX_VALUE;
		int N;
		long[] in, sTree, lazy;
		
		public SegmentTree(long[] array) {
			N = array.length - 1;
			in = array;
			sTree = new long[N<<1];
			lazy = new long[N<<1];
			build(1, 1, N);
		}
		
		public void build(int node, int b, int e) {
			if(b == e) {
				sTree[node] = in[b];
				return;
			}
			
			int left = node<<1, right = node<<1|1;
			int mid = (b + e)>>1;
			build(left, b, mid);
			build(right, mid + 1, e);
			sTree[node] = Math.min(sTree[left], sTree[right]);
		}
		
		public long query(int l, int r) {
			return query(1, 1, N, l, r);
		}
		
		public long query(int node, int b, int e, int l, int r) {
			if(l > e || r < b)
				return INF;
			if(b >= l && e <= r)
				return sTree[node];
			
			int left = node<<1, right = node<<1|1;
			int mid = (b + e)>>1;
			
			propagate(node, left, right);
			
			return Math.min(query(left, b, mid, l, r), query(right, mid + 1, e, l, r));
		}
		
		public void update_range(int l, int r, int v) {
			update_range(1, 1, N, l, r, v);
		}
		
		public void update_range(int node, int b, int e, int l, int r, int v) {
			if(e < l || b > r)
				return;
			if(b >= l && e <= r) {
				lazy[node] += v;
				sTree[node] += v;
				return;
			}
			
			int left = node<<1, right = node<<1|1;
			int mid = (b + e)>>1;
			
			propagate(node, left, right);
			
			update_range(left, b, mid, l, r, v);
			update_range(right, mid + 1, e, l, r, v);
			
			sTree[node] = Math.min(sTree[left], sTree[right]);
		}
		
		public void propagate(int node, int left, int right) {
			lazy[left] += lazy[node];
			lazy[right] += lazy[node];
			sTree[left] += lazy[node];
			sTree[right] += lazy[node];
			lazy[node] = 0;
		}
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

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

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public int[] nextIntArray(int n) throws IOException {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();
			return array;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] array = new Integer[n];
			for (int i = 0; i < n; i++)
				array[i] = new Integer(nextInt());
			return array;
		}

		public long[] nextLongArray(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();
			return array;
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		public static int[] shuffle(int[] a) {
			int n = a.length;
			Random rand = new Random();
			for (int i = 0; i < n; i++) {
				int tmpIdx = rand.nextInt(n);
				int tmp = a[i];
				a[i] = a[tmpIdx];
				a[tmpIdx] = tmp;
			}
			return a;
		}

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}
