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

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int a,i;
        String s[]=bu.readLine().split(" ");
        for(i=0;i<n;i++)
        {
            a=Integer.parseInt(s[i]);
            update(0,n,i,i+1,a,1);
        }

        int q=Integer.parseInt(bu.readLine());
        while(q-->0)
        {
            s=bu.readLine().trim().split(" ");
            if(s.length==3)
            {
                int l=Integer.parseInt(s[0]),r=Integer.parseInt(s[1]),v=Integer.parseInt(s[2]);
                if(r<l)
                {
                    update(0,n,l,n,v,1);
                    update(0,n,0,r+1,v,1);
                }
                else update(0,n,l,r+1,v,1);
            }
            else
            {
                int l=Integer.parseInt(s[0]),r=Integer.parseInt(s[1]);
                long ans;
                if(r<l) ans=Math.min(query(0,n,l,n,1),query(0,n,0,r+1,1));
                else ans=query(0,n,l,r+1,1);
                sb.append(ans+"\n");
            }
        }
        System.out.print(sb);
    }

    static int N=1<<19;
    static long st[]=new long[N],l[]=new long[N];

    static void update(int ss,int se,int us,int ue,int v,int n)
    {
        st[n]+=l[n];
        if(ss+1!=se)
        {
            l[2*n]+=l[n];
            l[2*n+1]+=l[n];
        }
        l[n]=0;

        if(ss>=ue || se<=us) return;
        if(ss>=us && se<=ue)
        {
            l[n]+=v;
            st[n]+=l[n];
            if(ss+1!=se)
            {
                l[2*n]+=l[n];
                l[2*n+1]+=l[n];
            }
            l[n]=0;
            return;
        }

        int mid=(se+ss)/2;
        update(ss,mid,us,ue,v,2*n);
        update(mid,se,us,ue,v,2*n+1);
        st[n]=Math.min(st[2*n],st[2*n+1]);
    }

    static long query(int ss,int se,int qs,int qe,int n)
    {
        st[n]+=l[n];
        if(ss+1!=se)
        {
            l[2*n]+=l[n];
            l[2*n+1]+=l[n];
        }
        l[n]=0;

        if(ss>=qe || se<=qs) return Long.MAX_VALUE;
        if(ss>=qs && se<=qe) return st[n];
        int mid=(se+ss)/2;
        return Math.min(query(ss,mid,qs,qe,2*n),query(mid,se,qs,qe,2*n+1));
    }
}