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.InputStreamReader;


public class CF_52C {
    static int n;
    static int[] A, M;
    static int[] flag;
    
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        n = Integer.parseInt(br.readLine());
        M = new int[4 * n];
        flag = new int[4 * n];
        A = new int[n];
        
        String[] line = br.readLine().split("\\s+");
        
        for (int i = 0; i < n; i++)
            A[i] = Integer.parseInt(line[i]);
        build(1, 0, n - 1);
        
        int m = Integer.parseInt(br.readLine());
        int lf, rg, v;
        
        while (m-- != 0) {
            line = br.readLine().split("\\s+");
            lf = Integer.parseInt(line[0]);
            rg = Integer.parseInt(line[1]);
            
            if (line.length == 2) {
                if (rg < lf)
                    System.out.println(Math.min(query(1, 0, n - 1, lf, n - 1), query(1, 0, n - 1, 0, rg)));
                else
                    System.out.println(query(1, 0, n - 1, lf, rg));
            }
            
            else {
                v = Integer.parseInt(line[2]);
                if (rg < lf) {
                    update(1, 0, n - 1, lf, n - 1, v);
                    update(1, 0, n - 1, 0, rg, v);
                }
                else
                    update(1, 0, n - 1, lf, rg, v);
            }
        }
    }
    
    static void build(int node, int b, int e) {
        if (b == e)
            M[node] = A[b];
        else {
            build(node * 2, b, (e + b) / 2);
            build(node * 2 + 1, (e + b) / 2 + 1, e);
            
            if (M[node * 2] <= M[node * 2 + 1])
                M[node] = M[node * 2];
            else
                M[node] = M[node * 2 + 1];
        }
    }
    
    static void update(int node, int b, int e, int p, int q, int v) {
        refresh(node);
        
        if (q < b || p > e)
            return;
        
        if (b >= p && e <= q) {
            flag[node] = v;
            refresh(node);
        }
        
        else {
            update(node * 2, b, (b + e) / 2, p, q, v);
            update(node * 2 + 1, (b + e) / 2 + 1, e, p, q, v);
            M[node] = Math.min(M[node * 2], M[node * 2 + 1]);
        }
    }
    
    static long query(int node, int b, int e, int p, int q) {
        refresh(node);
        
        if (q < b || p > e)
            return 1 << 30;
        
        if (b >= p && e <= q)
            return M[node];
        
        return Math.min(query(node * 2, b, (b + e) / 2, p, q), query(node * 2 + 1, (b + e) / 2 + 1, e, p, q));
    }
    
    static void refresh(int node) {
        if (flag[node] != 0) {
            M[node] += flag[node];
            
            if (2 * node < M.length)
                flag[2 * node] += flag[node];
            
            if (2 * node + 1 < M.length)
                flag[2 * node + 1] += flag[node];
            
            flag[node] = 0;
        }
    }
}
