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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C52 {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    IntervalTree it = new IntervalTree(0, n - 1);
    StringTokenizer st = new StringTokenizer(in.readLine());
    for (int i = 0; i < n; i++) {
      it.increment(i, i, Integer.parseInt(st.nextToken()));
    }
    int op = Integer.parseInt(in.readLine());
    PrintWriter out = new PrintWriter(new BufferedWriter(
        new OutputStreamWriter(System.out)));
    for (int i = 0; i < op; i++) {
      st = new StringTokenizer(in.readLine());
      int l = Integer.parseInt(st.nextToken());
      int r = Integer.parseInt(st.nextToken());
      if (st.countTokens() == 1) {
        int v = Integer.parseInt(st.nextToken());
        
        if (l <= r) {
          it.increment(l, r, v);
        } else {
          it.increment(l, n - 1, v);
          it.increment(0, r, v);
        }
      } else {
        long min = IntervalTree.inf;
        if (l <= r) {
          min = it.f(l, r, it.MIN);
        } else {
          min = Math.min(it.f(l, n - 1, it.MIN), it.f(0, r, it.MIN));
        }
        out.printf("%d\n", min);
      }
    }
    out.close();
  }
  static class IntervalTree {
    final static int MIN = 1, MAX = 2, SUM = 3;
    final static int inf = (int) 1e18;
    final static int[] bad = new int[]{0, inf, -inf, 0};
    int low, high;
    long[] vals; // ADD, MIN, MAX, SUM
    IntervalTree left, right;
    
    public IntervalTree(int l, int h) {
      this.low = l;
      this.high = h;
      vals = new long[4];
      if (low != high) {
        int mid = (low + high) / 2;
        left = new IntervalTree(low, mid);
        right = new IntervalTree(mid + 1, high);
      }
    }
    
    public void push() {
      if (vals[0] != 0) {
        right.increment(right.low, right.high, vals[0]);
        left.increment(left.low, left.high, vals[0]);
        vals[0] = 0;
      }
    }
    
    public void increment(int l, int h, long x) {
      if (h < l || l > high || h < low) return;
      l = Math.max(l, low);
      h = Math.min(h, high);
      if (l == low && h == high) {
        for (int i = 0; i < vals.length; i++)
          if (i != SUM) vals[i] += x;
        vals[SUM] += (high - low + 1) * x;
        return;
      }
      push();
      left.increment(l, h, x);
      right.increment(l, h, x);
      vals[MIN] = Math.min(left.vals[MIN], right.vals[MIN]);
      vals[MAX] = Math.max(left.vals[MAX], right.vals[MAX]);
      vals[SUM] = left.vals[SUM] + right.vals[SUM];
    }
    
    public long f(int l, int h, int i) {
      if (h < l || l > high || h < low) return bad[i];
      l = Math.max(l, low);
      h = Math.min(h, high);
      if (l == low && h == high) return vals[i];
      push();
      if (i == MIN) return Math.min(left.f(l, h, i), right.f(l, h, i));
      if (i == MAX) return Math.max(left.f(l, h, i), right.f(l, h, i));
      return left.f(l, h, i) + right.f(l, h, i);
    }
  }
}
