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.util.*;
 
public class templateJavaAdhoc
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
     static int n;
     static int[] lo,hi,tree;
     static int[] delta;
     public static void init(int a)
     {
         n=a;
         lo=new int[4*n+1];
         hi=new int[4*n+1];
         tree=new int[4*n+1];
         delta=new int[4*n+1];
     }
     public static void buildTree(int a[],int index,int l,int r)
     {
         lo[index]=l;
         hi[index]=r;
         if(l>r)
             return;
         if(l==r)
         {
             tree[index]=a[l];
             return;
         }
         int mid=(l+r)/2;
         buildTree(a,2*index,l,mid);
         buildTree(a,2*index+1,mid+1,r);
         tree[index]=Math.min(tree[2*index],tree[2*index+1]);
         
     }
     public static void propAll(int a[],int index,int l,int r)
     {
         int mid=(l+r)/2;
        if(l>r)
            return;
        if(l==r)
        {
            a[l]+=delta[index];
            delta[index]=0;
            return;
        }
        prop(index);
        
        propAll(a,2*index,l,mid);
        propAll(a,2*index+1,mid+1,r);
        
        update(index);
     }
     public static void prop(int i)
     {
         try{
         delta[2*i]+=delta[i];
         delta[2*i+1]+=delta[i];
         delta[i]=0;
         }
         catch(Exception e)
                 {
             System.out.println(i+" caught");
         }
     }
     public static void update(int i)
     {
         tree[i]=Math.min(tree[2*i]+delta[2*i],tree[2*i+1]+delta[2*i+1]);
     }
     public static void lazyUpdate(int i,int a,int b,int val)
     {
         try
         {
            if(hi[i]<a || b<lo[i])
                return;
            if(lo[i]>=a && hi[i]<=b)
            {
                delta[i]+=val;
                return;
            }
            prop(i);

            lazyUpdate(2*i,a,b,val);
            lazyUpdate(2*i+1,a,b,val);

            update(i);
         }
         catch(Exception e)
         {
             System.out.println(i+" "+a+" "+b+" "+val);
         }
     }
     public static int query(int i,int a,int b)
     {
         if(hi[i]<a || b<lo[i])
                return Integer.MAX_VALUE;
         if(lo[i]>=a && hi[i]<=b)
          {
                
              return tree[i]+delta[i];
          }
         prop(i);
         
         int minLeft=query(2*i,a,b);
         int minRight=query(2*i+1,a,b);
         
         update(i);
          
         return Math.min(minLeft,minRight);
     }
     public static void print(int a[])
     {
         System.out.println(Arrays.toString(a));
         System.out.println(Arrays.toString(lo));
         System.out.println(Arrays.toString(hi));
         System.out.println(Arrays.toString(tree));
         
     }
     public static void main(String args[]) throws IOException
     {
         //init(4);
         //int a[]={1,2,3,4};
         //buildTree(a,1,0,n-1);
         FastReader ob=new FastReader();
          n=ob.nextInt();
         int a[]=new int [n];
         String inp[];
         for(int i=0;i<n;i++)         
             a[i]=ob.nextInt();         
         init(n);
         buildTree(a,1,0,n-1);
         int q=ob.nextInt();
         StringBuilder sb=new StringBuilder("");
         while(q-->0)
         {
             inp=ob.nextLine().split(" ");
             if(inp.length==2)
             {
                 int x=Integer.parseInt(inp[0]);
                 int y=Integer.parseInt(inp[1]);
                 if(y<x)
                 sb.append(Math.min(query(1,x,n-1),query(1,0,y)));
                 else
                 sb.append(query(1,x,y));
                 sb.append("\n");
             }
             else
             {
                 int x=Integer.parseInt(inp[0]);
                 int y=Integer.parseInt(inp[1]);
                 int z=Integer.parseInt(inp[2]);
                 if(y<x)
                 {
                     lazyUpdate(1,x,n-1,z);
                     lazyUpdate(1,0,y,z);
                 }
                 else
                     lazyUpdate(1,x,y,z);
             }
         }
         System.out.println(sb);
         
     }
    
}
