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
#include <bits/stdc++.h>
using namespace std;
struct SegmentTree {
  long long int N, POW;
  vector<long long int> a, lazy;
  SegmentTree(long long int n, vector<long long int> &p) : N(n) {
    POW = pow(2, ceil(log2(N)));
    a = vector<long long int>(2 * POW);
    for (int i = POW + N; i < 2 * POW; ++i) a[i] = (1ll << 61);
    for (int i = POW, j = 0; i < POW + N; ++i, ++j) a[i] = p[j];
    lazy = vector<long long int>(2 * POW, 0);
    for (int i = POW - 1; i > 0; --i) {
      a[i] = (min(realVal((i * 2)), realVal((i * 2 | 1))));
    }
  }
  long long int realVal(long long int idx) { return a[idx] + lazy[idx]; }
  void applyLazy(long long int idx) {
    if (lazy[idx] != 0) {
      lazy[(idx * 2)] += lazy[idx];
      lazy[(idx * 2 | 1)] += lazy[idx];
      a[idx] = realVal(idx);
      lazy[idx] = 0;
    }
  }
  long long int getMin(long long int l, long long int r) {
    return getMin(l, r, 1, 0, POW);
  }
  long long int getMin(long long int l, long long int r, long long int idx,
                       long long int lb, long long int rb) {
    if ((l >= rb || lb >= r)) return (1ll << 61);
    if ((idx >= POW)) return realVal(idx);
    if ((l <= lb && rb <= r)) return realVal(idx);
    applyLazy(idx);
    long long int mid = (lb + rb) / 2;
    return (min(getMin(l, r, (idx * 2), lb, mid),
                getMin(l, r, (idx * 2 | 1), mid, rb)));
  }
  void add(long long int l, long long int r, long long int val) {
    add(l, r, val, 1, 0, POW);
  }
  void add(long long int l, long long int r, long long int val,
           long long int idx, long long int lb, long long int rb) {
    if ((l >= rb || lb >= r)) return;
    if ((idx >= POW)) {
      a[idx] += val;
      return;
    }
    if ((l <= lb && rb <= r)) {
      lazy[idx] += val;
      return;
    }
    applyLazy(idx);
    long long int mid = (lb + rb) / 2;
    add(l, r, val, (idx * 2), lb, mid);
    add(l, r, val, (idx * 2 | 1), mid, rb);
    a[idx] = (min(realVal((idx * 2)), realVal((idx * 2 | 1))));
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long int N;
  scanf("%lld", &N);
  vector<long long int> a(N);
  for (long long int &c : a) scanf("%lld", &c);
  SegmentTree st(N, a);
  long long int Q;
  scanf("%lld", &Q);
  for (int i = 0; i < Q; ++i) {
    long long int a, b, c, aa = 0, bb = 0;
    scanf("%lld", &a);
    scanf("%lld", &b);
    ++b;
    if (a >= b) {
      aa = 0;
      bb = b;
      b = N;
    }
    char w = getchar();
    ungetc(w, stdin);
    if (w == ' ') {
      scanf("%lld", &c);
      st.add(a, b, c);
      if (aa != bb) st.add(aa, bb, c);
    } else {
      long long int mn = 1ll << 62;
      mn = min(mn, st.getMin(a, b));
      if (aa != bb) mn = min(mn, st.getMin(aa, bb));
      printf("%lld\n", mn);
    }
  }
  return 0;
}
