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.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		CircularRMQ solver = new CircularRMQ();
		solver.solve(1, in, out);
		out.close();
	}
}

class CircularRMQ {
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        int n = in.nextInt();
        IntervalTree t = new IntervalTree(n);
        for (int i = 0; i < n; i++) {
            t.add(i, i, in.nextInt());
        }
        int m = in.nextInt();
        int a, b, c;
        for (int i = 0; i < m; i++) {
            a = in.nextInt();
            b = in.nextInt();
            if (!in.st.hasMoreTokens()) {
                if (a > b) {
                    out.println(Math.min(t.min(a, n - 1), t.min(0, b)));
                }
                else {
                    out.println(t.min(a, b));
                }
            }
            else {
                c = in.nextInt();
                if (a > b) {
                    t.add(a, n - 1, c);
                    t.add(0, b, c);
                }
                else {
                    t.add(a, b, c);
                }
            }
        }
    }
}

class PandaScanner {
    public BufferedReader br;
    public StringTokenizer st;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    public String next() {
        if (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(nextLine().trim());
            return next();
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
}

class IntervalTree {
    public int[] l;
    public int[] r;
    public long[] min;
//    public long[] sum;
    public long[] carry;

    public IntervalTree(int n) {
        l = new int[n << 3];
        r = new int[n << 3];
        min = new long[n << 3];
//        sum = new long[n << 2];
        carry = new long[n << 3];
        init(1, 0, n - 1);
    }

    public void add(int s, int t, long val) {
        add(1, s, t, val);
    }

    private void add(int idx, int s, int t, long val) {
        if (t < l[idx] || s > r[idx]) return;
        if (t >= r[idx] && s <= l[idx]) {
            min[idx] += val;
//            sum[idx] += (r[idx] - l[idx] + 1) * val;
            if (l[idx] != r[idx]) {
                carry[idx << 1] += val;
                carry[(idx << 1) + 1] += val;
            }
            return;
        }
        propagate(idx);
        add(idx << 1, s, t, val);
        add((idx << 1) + 1, s, t, val);
        update(idx);
    }

    public long min(int s, int t) {
        return min(1, s, t);
    }

    private long min(int idx, int s, int t) {
        if (t < l[idx] || s > r[idx]) return Long.MAX_VALUE;
        if (t >= r[idx] && s <= l[idx]) return min[idx] + carry[idx];
        propagate(idx);
        update(idx);
        return Math.min(min(idx << 1, s ,t), min((idx << 1) + 1, s ,t));
    }

    private void propagate(int idx) {
        carry[idx << 1] += carry[idx];
        carry[(idx << 1) + 1] += carry[idx];
        carry[idx] = 0;
    }

    private void update(int idx) {
//        sum[idx] = 0;
        int n = idx << 1;
        min[idx] = Math.min(min[n] + carry[n], min[n + 1] + carry[n + 1]);
//            sum[idx] += sum[i] + (r[i] - l[i] + 1) * carry[i];
    }

    private void init(int idx, int s, int t) {
        l[idx] = s;
        r[idx] = t;
        if (s != t) {
            int m = (s + t) >> 1;
            init((idx << 1), s, m);
            init((idx << 1) + 1, m + 1, t);
        }
    }

}

