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.util.*;
import java.io.*;


public class main{
    public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    public static PrintWriter pw = new PrintWriter(System.out);
    public static String line;
    public static StringTokenizer st;

    public static void main(String[] args) throws Exception{
        int N = Integer.parseInt(br.readLine());
        st = new StringTokenizer(br.readLine());
        long[] A = new long[N];
        for(int i = 0; i < N; i++){
            A[i] = Long.parseLong(st.nextToken());
        }

        int Q = Integer.parseInt(br.readLine());

        SegmentTree SGT = new SegmentTree(A);
        for(int i = 0; i < Q; i++){
            st = new StringTokenizer(br.readLine());
            int L = Integer.parseInt(st.nextToken());
            int R = Integer.parseInt(st.nextToken());

            if(st.hasMoreTokens()){
                int v = Integer.parseInt(st.nextToken());
                if(L <= R){
                    SGT.update(L, R, v);
                } else{
                    SGT.update(L, N-1, v);
                    SGT.update(0, R, v);
                }
            } else{
                long ans = 0;
                if(L <= R){
                    ans = SGT.rmq(L, R);
                } else{
                    ans = Math.min(SGT.rmq(L, N-1), SGT.rmq(0, R));
                }
                pw.print(ans + "\n");
            }
        }

        pw.close();
        br.close();
    }
}

class SegmentTree{
    private long[] st, A, lazy;
    private int n;
    private int left(int p) { return p << 1;}
    private int right(int p){ return (p << 1) + 1;}
    private long INF = (1L << 62);

    private void build(int p, int L, int R){
        if(L == R){
            st[p] = A[L];
        } else{
            build(left(p), L, (L+R)/2);
            build(right(p), (L+R)/2 + 1, R);
            long p1 = st[left(p)];
            long p2 = st[right(p)];
            st[p] = Math.min(p1, p2);
        }
    }

    private long rmq(int p, int L, int R, int i, int j){
        if(i > R || j < L){ return INF;}
        work(p, L, R);
        if(L >= i && R <= j) return st[p];
        long p1 = rmq(left(p), L, (L+R)/2, i, j);
        long p2 = rmq(right(p), (L+R)/2+1, R, i, j);
        return Math.min(p1, p2);
    }

    private void work(int p, int L, int R){
        if(lazy[p] != 0){
            st[p] += lazy[p];
            if(L != R){
                lazy[left(p)] += lazy[p];
                lazy[right(p)] += lazy[p];
            }
            lazy[p] = 0;
        }
    }

    private void update(int p, int L, int R, int i, int j, long value){
        work(p, L, R);
        if(R < i || L > j) return;
        if(L >= i && R <= j){
            st[p] += value;
            if(L != R){
                lazy[left(p)] += value;
                lazy[right(p)] += value;
            }
            return;
        }
        update(left(p), L, (L+R)/2, i, j, value);
        update(right(p), (L+R)/2 + 1, R, i, j, value);
        st[p] = Math.min(st[left(p)], st[right(p)]);
    }

    public SegmentTree(long[] _A){
        A = _A;
        n = A.length;
        st = new long[4*n];
        lazy = new long[4*n];
        build(1, 0, n-1);
    }

    public long rmq(int i, int j) { return rmq(1, 0, n-1, i, j); }
    public void update(int i, int j, long value){ update(1, 0, n-1, i, j, value); }
}
