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.*;
import java.math.*;
public class Solution{
    public static class SegmentTree{
        long tree[];
        long lazy[];
        SegmentTree(long[] arr,int n){
            int x = (int)(Math.ceil(Math.log(n)/Math.log(2)));
            int max_size = 2*(int)Math.pow(2,x)-1;
            tree = new long[max_size];
            lazy = new long[max_size];
            constructST(arr,n);
        }
        void constructST(long[] arr,int n){
            ConstructSTUtil(arr,0,n-1,0);
        }
        void ConstructSTUtil(long[] arr,int SS,int Se,int Si){
            if(SS>Se) return ;
            if(SS==Se){
                tree[Si] = arr[SS];
                return ;
            }
            int mid = (SS+Se)/2;
            ConstructSTUtil(arr,SS,mid,Si*2+1);
            ConstructSTUtil(arr,mid+1,Se,Si*2+2);
            tree[Si] = (long)Math.min(tree[Si*2+1],tree[Si*2+2]);
            
        }
        void updateRange(int n,int us,int ue,long diff){
            updateRangeUtil(0,0,n-1,us,ue,diff);
            //for(int i=0;i<tree.length;i++) System.out.println(tree[i]);
        }
        void updateRangeUtil(int Si,int SS,int Se,int us,int ue,long diff){
            if(lazy[Si]!=0){
                tree[Si] += lazy[Si];
                if(SS!=Se){
                    lazy[Si*2+1]+=lazy[Si];
                    lazy[Si*2+2]+= lazy[Si];
                }
                lazy[Si] = 0;
            }
            if(SS>Se||SS>ue||Se<us) return ;
            if(SS>=us&&Se<=ue){
                tree[Si] += diff;
                if(SS!= Se){
                    lazy[Si*2+1] += diff;
                    lazy[Si*2+2] += diff;
                }
                return ;
            }
            int mid = (SS+Se)/2;
            updateRangeUtil(Si*2+1,SS,mid,us,ue,diff);
            updateRangeUtil(Si*2+2,mid+1,Se,us,ue,diff);
            tree[Si] = (long)Math.min(tree[Si*2+1],tree[Si*2+2]);
            
            
        }
        long getMin(int n,int qs,int qe){
            return getMinUtil(0,n-1,qs,qe,0);
        }
        long getMinUtil(int SS,int Se,int qs,int qe,int Si){
            if(lazy[Si]!=0){
                tree[Si] += lazy[Si];
                if(SS!=Se){
                    lazy[Si*2+1] += lazy[Si];
                    lazy[Si*2+2] += lazy[Si];
                }
                lazy[Si] = 0;
            }
            if(SS>Se||SS>qe||Se<qs) return Long.MAX_VALUE;
            if(SS>=qs&&Se<=qe) return tree[Si];
            int mid = (SS+Se)/2;
            return (long)Math.min(getMinUtil(SS,mid,qs,qe,2*Si+1),getMinUtil(mid+1,Se,qs,qe,2*Si+2));
        }
    }
    public static void main(String[] args)throws IOException{
        BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        long[] a = new long[n] ;
        st = new StringTokenizer(br.readLine());
        for(int i=0;i<n;i++) a[i] = Long.parseLong(st.nextToken());
        SegmentTree lst = new SegmentTree(a,n);
        st = new StringTokenizer(br.readLine());
        int m = Integer.parseInt(st.nextToken());
        for(int i=0;i<m;i++){
            st = new StringTokenizer(br.readLine());
            int l = Integer.parseInt(st.nextToken());
            int r = Integer.parseInt(st.nextToken());
            if(st.hasMoreTokens()){
                long v = Long.parseLong(st.nextToken());
                if(l<=r) lst.updateRange(n,l,r,v);
                else {
                    lst.updateRange(n,0,r,v);
                    lst.updateRange(n,l,n-1,v);
                }
            }else{
                long min = Long.MAX_VALUE;
                if(l<=r) min = Math.min(min,lst.getMin(n,l,r));
                else {
                    min = Math.min(min,lst.getMin(n,0,r));
                    min = Math.min(min,lst.getMin(n,l,n-1));
                }
                out.println(min);
            }
        }
        out.flush();
   }
}