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
//                I know stuff but probably my rating tells otherwise...

//                  Love is no stone, it's soft... more like snow
//                        beautifying everything it covers
//                        And when it falls... you listen

//               Kya hua, code samajhne ki koshish kar rhe ho?? Mat karo,
//                      mujhe bhi samajh nhi aata kya likha hai


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

import static java.lang.Math.*;

public class _52C {

      static void Mangni_ke_bail_ke_dant_na_dekhal_jye() throws IOException {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            n = Integer.parseInt(br.readLine());

            init();

            StringTokenizer st = new StringTokenizer(br.readLine());

            for (int i = 0; i < n; i++) {
                  ar[i] = Integer.parseInt(st.nextToken());
            }

            build(1, 0, n - 1);

            t = Integer.parseInt(br.readLine());

            while (t-- > 0) {

                  st = new StringTokenizer(br.readLine());
//                  pl(Arrays.toString(seg));
//                  pl(Arrays.toString(lazy));
                  if (st.countTokens() == 2) {
                        int x = Integer.parseInt(st.nextToken());
                        int y = Integer.parseInt(st.nextToken());

                        if (y < x) {
                              pl(min(query(1, 0, n - 1, x, n - 1), query(1, 0, n - 1, 0, y)));
                        } else pl(query(1, 0, n - 1, x, y));
                  } else {
                        int x = Integer.parseInt(st.nextToken());
                        int y = Integer.parseInt(st.nextToken());
                        int z = Integer.parseInt(st.nextToken());

                        if (y < x) {
                              update(1, 0, n - 1, x, n - 1, z);
                              update(1, 0, n - 1, 0, y, z);
                        } else update(1, 0, n - 1, x, y, z);
                  }
            }
      }

      static long seg[];
      static int ar[];
      static long lazy[];

      static void init() {
            seg = new long[(n << 2) + 5];
            ar = new int[n];
            lazy = new long[(n << 2) + 5];
      }

      static void build(int i, int l, int r){
            if(l == r){
                  seg[i] = ar[l];
                  return;
            }
            int mid = l + r >> 1;
            build(i << 1, l, mid);
            build(i << 1 | 1, mid + 1, r);
            seg[i] = min(seg[i << 1], seg[i << 1 | 1]);
      }

      static void update(int i, int l, int r, int L, int R, int val){

            if (r < L || l > R) return;// Long.MAX_VALUE;
            //lazy_propagate(i, l, r);
            if(l >= L && r <= R){
                  lazy[i] += val;
                  seg[i] += val;
                  return;
            }
            lazy_propagate(i, l, r);
            int mid = l + r >> 1;
            update(i << 1, l ,mid, L, R, val);
            update(i << 1 | 1, mid + 1, r, L, R, val);

            seg[i] = min(seg[i << 1], seg[i << 1 | 1]);
      }

      static long query(int i, int l, int r, int L, int R) {
//            p(i);
//            p(l);
//            p(r);
//            p(L);
//            pl(R);
            if (r < L || l > R) return Long.MAX_VALUE;
            //lazy_propagate(i, l, r);
            if (l >= L && r <= R) {
                  return seg[i];
            }
            lazy_propagate(i, l, r);
            int mid = l + r >> 1;
            return min(query(i << 1, l, mid, L, R),
                    query(i << 1 | 1, mid + 1, r, L, R));
      }

      static void lazy_propagate(int i, int l, int r){
            if(lazy[i] == 0)return;
            if(l != r){
                  lazy[i << 1] += lazy[i];
                  lazy[i << 1 | 1] += lazy[i];
                  seg[i << 1] += lazy[i];
                  seg[i << 1 | 1] +=lazy[i];
            }
            //seg[i] += lazy[i];
            lazy[i] = 0;
      }


//----------------------------------------The main code ends here------------------------------------------------------
/*-------------------------------------------------------------------------------------------------------------------*/
//-----------------------------------------Rest's all dust-------------------------------------------------------------


static int mod9=1_000_000_007;
static int n,m,l,k,t;
static AwesomeInput input;
static PrintWriter pw;

static long power(long a,long b){
        long x=max(a,b);
        if(b==0)return 1;
        if((b&1)==1)return a*power(a*a,b>>1);
        return power(a*a,b>>1);
        }

static long modpow(long a,long b,long m){
        if(b==0)return 1;

        if((b&1)==1)return a*modpow(a*a%m,b>>1,m)%m;
        return modpow(a*a%m,b>>1,m)%m;
        }

// The Awesome Input Code is a fast IO method //
static class AwesomeInput {
      private InputStream letsDoIT;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      private AwesomeInput(InputStream incoming) {
            this.letsDoIT = incoming;
      }

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

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

      private String ForString() {
            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 boolean isSpaceChar(int c) {
            if (filter != null)
                  return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }

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

}

      // functions to take input//
      static int ni() {
            return (int) input.ForLong();
      }

      static String ns() {
            return input.ForString();
      }

      static long nl() {
            return input.ForLong();
      }

      //functions to give output
      static void pl() {
            pw.println();
      }

      static void p(Object o) {
            pw.print(o + " ");
      }

      static void pws(Object o) {
            pw.print(o + "");
      }

      static void pl(Object o) {
            pw.println(o);
      }

      // Fast Sort is Radix Sort
      public static int[] fastSort(int[] f) {
            int n = f.length;
            int[] to = new int[n];
            {
                  int[] b = new int[65537];
                  for (int i = 0; i < n; i++) b[1 + (f[i] & 0xffff)]++;
                  for (int i = 1; i <= 65536; i++) b[i] += b[i - 1];
                  for (int i = 0; i < n; i++) to[b[f[i] & 0xffff]++] = f[i];
                  int[] d = f;
                  f = to;
                  to = d;
            }
            {
                  int[] b = new int[65537];
                  for (int i = 0; i < n; i++) b[1 + (f[i] >>> 16)]++;
                  for (int i = 1; i <= 65536; i++) b[i] += b[i - 1];
                  for (int i = 0; i < n; i++) to[b[f[i] >>> 16]++] = f[i];
                  int[] d = f;
                  f = to;
                  to = d;
            }
            return f;
      }

      public static void main(String[] args) {      //threading has been used to increase the stack size.
            try {
                  input = new AwesomeInput(System.in);
                  pw = new PrintWriter(System.out, true);
//                  input = new AwesomeInput(new FileInputStream("/home/saurabh/Desktop/input.txt"));
                  pw = new PrintWriter(new BufferedWriter(new FileWriter("/home/saurabh/Desktop/output.txt")), true);

            } catch (Exception e) {
            }

            new Thread(null, null, "AApan_gand_hawai_dusar_ke_kare_dawai", 1 << 25)  //the last parameter is stack size desired.
            {
                  public void run() {
                        try {
                              double s = System.currentTimeMillis();
                              Mangni_ke_bail_ke_dant_na_dekhal_jye();
                              //System.out.println(("\nExecution Time : " + ((double) System.currentTimeMillis() - s) / 1000) + " s");
                              pw.flush();
                              pw.close();
                        } catch (Exception e) {
                              e.printStackTrace();
                              System.exit(1);
                        }
                  }
            }.start();
      }
}