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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class CircularRMQ {
    static long[]resistance;
    static long[]tree;
    static long []lazy;
    static int max = 524288;
    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        sc = new StringTokenizer("");
        tree = new long[max];
        lazy = new long[max];
        int n = nxtInt();
        resistance = nxtLngArr(n);
        build(0, 0, n-1);
        int m = nxtInt();
        while(m > 0){
            String []s = br.readLine().split(" ");
            int r = Integer.parseInt(s[1]);
            int l = Integer.parseInt(s[0]);
            if(s.length == 2){
                long ans;
                if(l > r){
                     ans = Math.min(query(0, 0, n-1, l, n-1), query(0, 0, n-1, 0, r));
                }else{
                    ans = query(0, 0, n-1, l, r);
                }
                out.println(ans);
            }else{
                int v = Integer.parseInt(s[2]);
                if(l > r){
                    update(0, 0, n-1, l, n-1 , v);
                    update(0, 0, n-1, 0, r , v);
                }else{
                    update(0, 0, n-1, l, r , v);
                }
            }
            
            m--;
        }
        out.close();
        

    }
    static void lazy(int i , int l , int r ){
        if (l != r) {
            lazy[i * 2 + 1] += lazy[i];
            lazy[i * 2 + 2] += lazy[i];
        }
        tree[i]+=lazy[i];
        lazy[i] = 0;
    }
    static void build(int i , int li , int ri){
        if(li == ri){
            tree[i] = resistance[li];
            return;
        }
        build(i*2+1 , li , (ri+li)/2);
        build(i*2+2 , (li+ri)/2 +1 ,ri);
        tree[i] = Math.min(tree[i*2+1],tree[i*2+2]);
            
    }
    static long query(int i , int li , int ri , int a , int b){
        lazy(i , li , ri);
        if(li > b || ri < a)
            return Long.MAX_VALUE;
        if(li  >= a && b >=  ri)
            return tree[i];
        return Math.min(query(i*2+1, li, (ri+li)/2, a, b) , query(i*2+2, (li+ri)/2+1, ri, a, b));
        
    }
    static void update(int i , int li , int ri , int a , int b , int value){
        lazy(i , li , ri);
        if(li >= a && b >= ri){
            lazy[i]+=value;
            lazy(i , li , ri);
            return ;
        }
        if(li > b || ri < a ){
            return;
        }
        update(i*2+1, li, (ri+li)/2, a, b, value);
        update(i*2+2, (li+ri)/2+1,ri, a, b, value);
        tree[i] = Math.min(tree[i*2+1],tree[i*2+2]);
    }
    static BufferedReader br;
    static StringTokenizer sc;
    static PrintWriter out;

    static String nxtTok() throws IOException {
        while (!sc.hasMoreTokens()) {
            String s = br.readLine();
            if (s == null)
                return null;
            sc = new StringTokenizer(s.trim());
        }
        return sc.nextToken();
    }

    static int nxtInt() throws IOException {
        return Integer.parseInt(nxtTok());
    }

    static long nxtLng() throws IOException {
        return Long.parseLong(nxtTok());
    }

    static double nxtDbl() throws IOException {
        return Double.parseDouble(nxtTok());
    }

    static int[] nxtIntArr(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nxtInt();
        return a;
    }

    static long[] nxtLngArr(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nxtLng();
        return a;
    }

    static char[] nxtCharArr() throws IOException {
        return nxtTok().toCharArray();
    }


}
