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 Main implements Runnable {
    
    final long infinity = 200001000000L;

    class Node {
        long min, add;
        Node left, right;
        
        Node(long min, long add, 
             Node left, Node right)
        {
            this.min = min;
            this.add = add;
            this.left = left;
            this.right = right;
        }

        boolean isLeaf() {
            return left == null && right == null;
        }
    }

    int n;
    int[] as;
    Node tree;

    Node build(int l, int r) {
        if(l > r)
            return null;
        if(l == r) {
            return new Node(as[l], 0, null, null);
        } else {
            int m = (l + r) / 2;
            Node left = build(l, m);
            Node right = build(m + 1, r);
            return new Node(Math.min(left.min, right.min), 0, left, right);
        }
    }

    void inc(Node v, int tl, int tr, int l, int r, int value) {
        if(l > r) 
            return;
        else if(l == tl && r == tr) {
            v.add += value;
        } else {
            int tm = (tl + tr) / 2;
            inc(v.left, tl, tm, l, Math.min(r, tm), value);
            inc(v.right, tm + 1, tr, Math.max(l, tm + 1), r, value);
            v.min = Math.min(v.left.min + v.left.add,
                             v.right.min + v.right.add);
        }
    }

    long min(Node v, int tl, int tr, int l, int r) {
        if(l > r)
            return infinity;
        else if(l == tl && r == tr) {
            return v.min + v.add;
        } else {
            int tm = (tl + tr) / 2;

            long lm = min(v.left, tl, tm, l, Math.min(r, tm)) + v.add;
            long rm = min(v.right, tm + 1, tr, Math.max(l, tm + 1), r) + v.add;

            return Math.min(lm, rm);
        }
    }

    void show(Node node, int lvl) {
        if(node != null) {
            show(node.right, lvl + 1);

            for(int i = 0; i < 4 * lvl; ++i)
                out.print(' ');
            out.print("(");
            out.print(node.min);
            out.print(",");
            out.print(node.add);
            out.println(")");

            show(node.left, lvl + 1);
        }
    }

    void solve() throws IOException {
        n = nextInt();
        as = new int[n];
        for(int i = 0; i < n; ++i)
            as[i] = nextInt();
        tree = build(0, n - 1);

        int k = nextInt();
        while(k-- > 0) {
            String[] ss = in.readLine().split("\\s");

            int l = Integer.valueOf(ss[0]);
            int r = Integer.valueOf(ss[1]);

            if(ss.length == 2) {
                if(l <= r)
                    out.println(min(tree, 0, n - 1, l, r));
                else
                    out.println(Math.min(min(tree, 0, n - 1, 0, r),
                                         min(tree, 0, n - 1, l, n - 1)));
            } else {
                int v = Integer.valueOf(ss[2]);
                if(l <= r)
                    inc(tree, 0, n - 1, l, r, v);
                else {
                    inc(tree, 0, n - 1, 0, r, v);
                    inc(tree, 0, n - 1, l, n - 1, v);
                }
            }
        }
    }

    @Override
    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = System.out;
            solve();
            in.close();
            out.close();
        } catch(IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    BufferedReader in;
    PrintStream out;
    StringTokenizer tok;

    String nextToken() throws IOException {
        while(tok == null || !tok.hasMoreTokens())
            tok = new StringTokenizer(in.readLine());
        return tok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.valueOf(nextToken());
    }

    long nextLong() throws IOException {
        return Long.valueOf(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.valueOf(nextToken());
    }

    public static void main(String[] args) {
        new Main().run();
    }
}
