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.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class SPOJANDCC
{
	@SuppressWarnings("rawtypes")
	static InputReader in;
	static PrintWriter out;

	static class SegmentTree
	{
		int n;
		long arr[], lazy[];

		SegmentTree(int n)
		{
			arr = new long[n << 2];
			lazy = new long[n << 2];
		}

		SegmentTree(long a[])
		{
			this.n = a.length;
			arr = new long[n << 2];
			lazy = new long[n << 2];
			build(0, n - 1, 0, a);
		}

		void build(int l, int r, int c, long a[])
		{
			if (l == r)
			{
				arr[c] = a[l];
				return;
			}
			int mid = l + r >> 1;
			build(l, mid, (c << 1) + 1, a);
			build(mid + 1, r, (c << 1) + 2, a);
			arr[c] = merge(arr[(c << 1) + 1], arr[(c << 1) + 2]);
		}

		long merge(long a, long b)
		{
			return Math.min(a, b);
		}

		long lazymerge(long a, long b)
		{
			return a + b;
		}

		boolean getInitialValue(long a)
		{
			return !(a == 0);
		}

		void check(int c, int l, int r)
		{
			if (getInitialValue(lazy[c]))
			{
				arr[c] = lazymerge(arr[c], lazy[c]);
				if (l != r)
				{
					lazy[(c << 1) + 1] = lazymerge(lazy[(c << 1) + 1], lazy[c]);
					lazy[(c << 1) + 2] = lazymerge(lazy[(c << 1) + 2], lazy[c]);
				}
				lazy[c] = 0;
			}
		}

		void update(int l, int r, int c, int x, int y, int val)
		{
			check(c, l, r);
			if (l > r || x > y || l > y || x > r)
				return;
			if (x <= l && y >= r)
			{
				arr[c] = lazymerge(arr[c], val);
				if (l != r)
				{
					lazy[(c << 1) + 1] = lazymerge(lazy[(c << 1) + 1], val);
					lazy[(c << 1) + 2] = lazymerge(lazy[(c << 1) + 2], val);
				}
				return;
			}
			int mid = l + r >> 1;
			update(l, mid, (c << 1) + 1, x, y, val);
			update(mid + 1, r, (c << 1) + 2, x, y, val);
			arr[c] = merge(arr[(c << 1) + 1], arr[(c << 1) + 2]);
		}

		void up(int x, int y, int val)
		{
			update(0, n - 1, 0, x, y, val);
		}

		long get(int l, int r, int c, int x, int y)
		{
			check(c, l, r);
			if (l > r || x > y || l > y || x > r) // return inverse value
				return Long.MAX_VALUE;
			else if (x <= l && y >= r)
				return arr[c];
			int mid = l + r >> 1;
			return merge(get(l, mid, (c << 1) + 1, x, y), get(mid + 1, r, (c << 1) + 2, x, y));
		}

		long ans(int x, int y)
		{
			return get(0, n - 1, 0, x, y);
		}
	}

	static void solve()
	{
		int n = in.ni();
		long arr[] = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = in.nl();
		SegmentTree m = new SegmentTree(arr);
		int t = in.ni();
		while (t-- > 0)
		{
			String h[] = in.nextLine().split(" ");
			if (h.length == 2)
			{
				int x = Integer.parseInt(h[0]);
				int y = Integer.parseInt(h[1]);
				if (x > y)
					out.println(Math.min(m.ans(x, n - 1), m.ans(0, y)));
				else
					out.println(m.ans(x, y));
			} else
			{
				int x = Integer.parseInt(h[0]);
				int y = Integer.parseInt(h[1]);
				int z = Integer.parseInt(h[2]);
				if (x > y)
				{
					m.up(x, n - 1, z);
					m.up(0, y, z);
				} else
					m.up(x, y, z);
			}
		}
	}

	@SuppressWarnings("rawtypes")
	static void soln()
	{
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args)
	{
		new Thread(null, new Runnable()
		{
			public void run()
			{
				try
				{
					soln();
				} catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	static class InputReader<SpaceCharFilter>
	{

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

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

		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				} catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

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

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

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = ni();
			}
			return a;
		}

		public long[] nextLongArray(int n)
		{
			long a[] = new long[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nl();
			}
			return a;
		}

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

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

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

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

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}

	}
}