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;


public class Main {
    

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] nums = in.readLine().split(" ");
        long[] a = new long[n];
        for(int i = 0; i < n; ++i) a[i] = Integer.parseInt(nums[i]);
        RmqUtil u = new RmqUtil(a);
        
        int m = Integer.parseInt(in.readLine());
        for(int i = 0; i < m; ++i) {
            nums = in.readLine().split(" ");
            int lf = Integer.parseInt(nums[0]);
            int rg = Integer.parseInt(nums[1]);
            if(nums.length == 2) {
                //rmq
                if(lf <= rg) System.out.println(u.rmq(lf,rg));
                else {
                    System.out.println(Math.min(u.rmq(lf,a.length-1),u.rmq(0,rg)));
                }
            } else {
                //set
                int v = Integer.parseInt(nums[2]);
                if(lf <= rg) {
                    u.inc(lf,rg,v);
                } else {
                    u.inc(lf,a.length-1,v);
                    u.inc(0,rg,v);
                }
            }
        }
    }
    
    
    
    
    
    
    
    
    
    


    
    
    
    static class RmqUtil {
        private final long[] a;
        //st[node] = (min value in a[b],...,a[e])-add[node] where (b,...,e) is the segment associated with node
        private final long[] st; 
        private final long[] add;
       
        //O(n)
        public RmqUtil(long[] a) {
            this.a = a;
            st = new long[4*a.length];
            add = new long[st.length];
            init(0,0,a.length-1);
        }
        private void init(int node, int b, int e) {
            if(b == e) st[node] = a[b];
            else {
                init(2*node+1,b,(b+e)/2);
                init(2*node+2,(b+e)/2+1,e);
                st[node] = Math.min(st[2*node+1],st[2*node+2]); 
            }
        }
        
        //RETURNS: Min value in a[i],...,a[j]. O(logn)
        public long rmq(int i, int j) {
            return rmq(0,0,a.length-1,i,j);
        }
        //RETURNS: Min value in (b,...,e) intersect (i,...,j) or Long.MAX_VALUE if intersection is empty.
        private long rmq(int node, int b, int e, int i, int j) {
            if(i > e || j < b) return Long.MAX_VALUE;
            if(b >= i && e <= j) return add[node]+st[node];
            return add[node]+Math.min(rmq(2*node+1,b,(b+e)/2,i,j),rmq(2*node+2,(b+e)/2+1,e,i,j));
        }
        
        //Increment a[i],...,a[j] by value. O(logn)
        public void inc(int i, int j, int delta) {
            inc(0,0,a.length-1,i,j,delta);
        }
        private void inc(int node, int b, int e, int i, int j, int delta) {
            if(i > e || j < b) return;
            if(b >= i && e <= j) {
                add[node] += delta;
                return;
            }
            inc(2*node+1,b,(b+e)/2,i,j,delta);
            inc(2*node+2,(b+e)/2+1,e,i,j,delta);
            st[node] = Math.min(add[2*node+1]+st[2*node+1],add[2*node+2]+st[2*node+2]);
        }
        
        /*
        //RETURNS: Value of a[index]. O(logn)
        public long get(int index) {
            long res = a[index];
            int node = 0, b = 0, e = a.length-1;
            while(b != e) {
                res += add[node];
                if(index <= (b+e)/2) e = (b+e)/2;
                else b = (b+e)/2+1;
            }
            return res;
        }
        */
    }


}
