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
/*
 * 
 * @Author  Ajudiya_13(Bhargav Girdharbhai Ajudiya)
 * Dhirubhai Ambani Institute of Information And Communication Technology 
 * 
 */


import java.util.*;
import java.io.*;
import java.lang.*;

public class Code119
{
	
	private static long mod = 1000000007;
	static class InputReader {
		 
		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 nextInt() {
			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 nextLong() {
			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] = nextInt();
			}
			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);
		}
	}
	
	static class SegmentTreeUiR
	{
		int st[];
		int lazy[];
		
		SegmentTreeUiR(int[] a, int n)
		{
			int x = (int)(Math.ceil(Math.log(n)/Math.log(2)));
			int MaxSize = 2*(int)Math.pow(2, x)-1;
			
			st = new int[5000000];
			lazy = new int[5000000];
			constructST(a,0,n-1,0);
		}
		
		int minVal(int x,int y)
		{
			return Math.min(x, y);
		}
		
		int getMid(int x,int y)
		{
			return (x+y)/2;
		}
		
		int constructST(int[] a,int ss,int se, int si)
		{
			if(ss==se)
			{
				st[si] = a[ss];
				return a[ss];
			}
			
			int mid = getMid(ss, se);
			st[si] = minVal(constructST(a, ss, mid, 2*si+1), 
					constructST(a, mid+1, se, 2*si+2));
			
			return st[si];
		}
		
		int RMQ(int ss, int se, int qs, int qe, int index)
		{
			if(lazy[index]!=0)
			{
				st[index] += lazy[index];
				lazy[2*index+1] += lazy[index];
				lazy[2*index+2] += lazy[index];
				lazy[index] = 0;
			}
			
			if(se<qs || ss>qe)
				return Integer.MAX_VALUE;
			
			if(qs<=ss && qe>=se)
				return st[index];
			
			int mid = getMid(ss, se);
			return Math.min(RMQ(ss, mid, qs, qe, 2*index+1), 
					RMQ(mid+1, se, qs, qe, 2*index+2));
			
		}
		
		void updateRange(int ss, int se, int qs, int qe, int index, int diff)
		{
			if(lazy[index]!=0)
			{
				st[index] += lazy[index];
				lazy[2*index+1] += lazy[index];
				lazy[2*index+2] += lazy[index];
				lazy[index] = 0;
			}
				
			if(ss>qe || se<qs || qs>qe)
				return;
			
			if(qs<=ss && qe>=se)
			{
				st[index] += diff;
				lazy[2*index+1] += diff;
				lazy[2*index+2] += diff;
				return;
			}
			
			int  mid = getMid(ss, se);
			updateRange(ss, mid, qs, qe, 2*index+1, diff);
			updateRange(mid+1, se, qs, qe, 2*index+2, diff);
			
			st[index] = Math.min(st[2*index+1], st[2*index+2]);
		}
	}
	
	public static void main(String[] args)
	{
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = in.nextInt();
		int[] a = in.nextIntArray(n);
		
		SegmentTreeUiR segment = new SegmentTreeUiR(a, n);
		
		int m = in.nextInt();
		for(int i=0;i<m;i++)
		{
			String s[] = in.nextLine().split(" ");
			if(s.length==2)
			{
				int qs = Integer.parseInt(s[0]);
				int qe = Integer.parseInt(s[1]);
				
				if(qs>qe)
					pw.println(Math.min(segment.RMQ(0, n-1, qs, n-1, 0), 
							segment.RMQ(0, n-1, 0, qe, 0)));
				
				else
					pw.println(segment.RMQ(0, n-1, qs, qe, 0));
			}
			
			else
			{
				int qs = Integer.parseInt(s[0]);
				int qe = Integer.parseInt(s[1]);
				int diff = Integer.parseInt(s[2]);
				
				if(qs>qe)
				{
					segment.updateRange(0, n-1, qs, n-1, 0, diff);
					segment.updateRange(0, n-1, 0, qe, 0, diff);
				}
				
				else
					segment.updateRange(0, n-1, qs, qe, 0, diff);
			}
			
		}
		pw.flush();
		pw.close();
	}
}