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;
template <typename T>
struct SegmentTree {
  vector<T> tree, lazy;
  T id;
  T neutral;
  int n;
  SegmentTree(int _n, T _id, T _neutral) : n(_n), id(_id), neutral(_neutral) {
    tree.assign(4 * n, id);
    lazy.assign(4 * n, neutral);
  }
  T combine(const T& a, const T& b) { return min(a, b); }
  inline void buildTree(vector<T>& src, int idx, int l, int r) {
    if (l == r) {
      tree[idx] = src[l];
    } else {
      int mid = (l + r) / 2;
      buildTree(src, 2 * idx, l, mid);
      buildTree(src, 2 * idx + 1, mid + 1, r);
      tree[idx] = combine(tree[2 * idx], tree[2 * idx + 1]);
    }
  }
  void push(int idx) {
    tree[2 * idx] += lazy[idx];
    tree[2 * idx + 1] += lazy[idx];
    lazy[2 * idx] += lazy[idx];
    lazy[2 * idx + 1] += lazy[idx];
    lazy[idx] = 0;
  }
  void update(int idx, int tl, int tr, int l, int r, T delta) {
    if (l > r) return;
    if (tl == l && tr == r) {
      tree[idx] += delta;
      lazy[idx] += delta;
    } else {
      push(idx);
      int tm = (tl + tr) / 2;
      update(idx * 2, tl, tm, l, min(r, tm), delta);
      update(idx * 2 + 1, tm + 1, tr, max(l, tm + 1), r, delta);
      tree[idx] = combine(tree[idx * 2], tree[idx * 2 + 1]);
    }
  }
  T query(int idx, int tl, int tr, int l, int r) {
    if (l > r) return id;
    if (l <= tl && tr <= r) return tree[idx];
    push(idx);
    int tm = (tl + tr) / 2;
    return combine(query(idx * 2, tl, tm, l, min(r, tm)),
                   query(idx * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  SegmentTree<long long> st(n, 1000LL * 1000LL * 1000LL * 1000LL, 0);
  vector<long long> vec(n);
  for (auto& x : vec) cin >> x;
  st.buildTree(vec, 1, 0, n - 1);
  int q;
  cin >> q;
  string s;
  getline(cin, s);
  for (int(i) = (0); (i) < (q); ++(i)) {
    getline(cin, s);
    istringstream linha(s);
    vector<long long> vals;
    long long x;
    while (linha >> x) {
      vals.emplace_back(x);
    }
    if ((int)vals.size() == 2) {
      long long left = vals[0], right = vals[1];
      if (left > right) {
        long long a = st.query(1, 0, n - 1, left, n - 1);
        long long b = st.query(1, 0, n - 1, 0, right);
        cout << min(a, b) << endl;
      } else
        cout << st.query(1, 0, n - 1, left, right) << endl;
    } else {
      long long left = vals[0], right = vals[1], delta = vals[2];
      if (left > right) {
        st.update(1, 0, n - 1, left, n - 1, delta);
        st.update(1, 0, n - 1, 0, right, delta);
      } else
        st.update(1, 0, n - 1, left, right, delta);
    }
  }
  return 0;
}
