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.*;

import static java.lang.Integer.parseInt;

public class C {

	private static void solve() throws IOException {
		int n = parseInt(br.readLine().trim());
		long[] a = new long[n];
		StringTokenizer st = new StringTokenizer(br.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = parseInt(st.nextToken());
		}
		SegmentTreeMin tree = new SegmentTreeMin(a);

		int q = parseInt(br.readLine().trim());
		int[] buf = new int[3];
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(br.readLine());
			int cnt = 0;
			while (st.hasMoreTokens()) {
				buf[cnt++] = parseInt(st.nextToken());
			}
			int l = buf[0], r = buf[1];
			r = (r + 1) % n;
			if (cnt == 3) {
				tree.add(l, r, buf[2]);
			} else {
				System.out.println(tree.get(l, r));
			}
		}
	}

	public static class SegmentTreeMin {
		final static long INF = 1L << 62;
		int h, n;
		long[] min;

		SegmentTreeMin(int n) {
			this.n = n;
			while (1 << h < n)
				h++;
			min = new long[1 << h + 1];
			Arrays.fill(min, INF);
			min[0] = 0;
		}

		SegmentTreeMin(long[] x) {
			this(x.length);
			System.arraycopy(x, 0, min, 1 << h, n);
			for (int i = (1 << h) - 1; i > 0; i--) {
				min[i] = Math.min(min[2 * i], min[2 * i + 1]);
			}
		}

		void add(int l, int r, long val) {
			if (r <= l) {
				add1(0, r, 1, 0, 1 << h, val);
				add1(l, n, 1, 0, 1 << h, val);
			} else
				add1(l, r, 1, 0, 1 << h, val);
		}

		void add1(int l, int r, int i, int from, int to, long val) {
			if (from >= r || to <= l)
				return;
			if (from >= l && to <= r) {
				min[i] += val;
			} else {
				int m = (from + to) / 2;
				min[i] -= Math.min(min[2 * i], min[2 * i + 1]);
				add1(l, r, 2 * i, from, m, val);
				add1(l, r, 2 * i + 1, m, to, val);
				min[i] += Math.min(min[2 * i], min[2 * i + 1]);
			}
		}

		long get(int l, int r) {
			long ret;
			if (r <= l) {
				long a = get1(0, r, 1, 0, 1 << h);
				long b = get1(l, n, 1, 0, 1 << h);
				ret = Math.min(a, b);
			} else
				ret = get1(l, r, 1, 0, 1 << h);
			return ret;
		}

		long get1(int l, int r, int i, int from, int to) {
			if (from >= r || to <= l)
				return INF;
			if (from >= l && to <= r) {
				return min[i];
			} else {
				int m = (from + to) / 2;
				long add = min[i] - Math.min(min[2 * i], min[2 * i + 1]);
				long a = get1(l, r, 2 * i, from, m);
				long b = get1(l, r, 2 * i + 1, m, to);
				return Math.min(a, b) + add;
			}
		}

	}

	static BufferedReader br;

	public static void main(String[] args) {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			solve();
			System.out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(239);
		}
	}
}