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;
class SegmentTree {
  int n;
  vector<int> tree;
  vector<int> lo;
  vector<int> hi;
  vector<int> delta;
  void update(int i) {
    tree[i] = min(tree[2 * i + 1] + delta[2 * i + 1],
                  tree[2 * i + 2] + delta[2 * i + 2]);
  }
  void prop(int i) {
    delta[2 * i + 1] += delta[i];
    delta[2 * i + 2] += delta[i];
    delta[i] = 0;
  }
  void increment(int i, int left, int right, int val) {
    if (left > hi[i] || right < lo[i]) return;
    if (left <= lo[i] && hi[i] <= right) {
      delta[i] += val;
      return;
    }
    prop(i);
    increment(2 * i + 1, left, right, val);
    increment(2 * i + 2, left, right, val);
    update(i);
  }
  int minimum(int i, int left, int right) {
    if (left > hi[i] || right < lo[i]) return INT_MAX;
    if (left <= lo[i] && hi[i] <= right) {
      return tree[i] + delta[i];
    }
    prop(i);
    int minLeft = minimum(2 * i + 1, left, right);
    int minRight = minimum(2 * i + 2, left, right);
    update(i);
    return min(minLeft, minRight);
  }

 public:
  SegmentTree(int n) : n(n) {
    tree = vector<int>(4 * n);
    lo = vector<int>(4 * n);
    hi = vector<int>(4 * n);
    delta = vector<int>(4 * n);
    init(0, 0, n - 1);
  }
  void init(int i, int left, int right) {
    lo[i] = left;
    hi[i] = right;
    if (left == right) return;
    int mid = (left + right) / 2;
    init(2 * i + 1, left, mid);
    init(2 * i + 2, mid + 1, right);
  }
  void increment(int left, int right, int val) {
    increment(0, left, right, val);
  }
  int minimum(int left, int right) { return minimum(0, left, right); }
};
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  SegmentTree st(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    st.increment(i, i, a);
  }
  int m;
  cin >> m;
  cin.ignore(256, '\n');
  for (int i = 0; i < m; i++) {
    vector<int> tmp;
    while (cin.peek() != '\n') {
      int num;
      cin >> num;
      tmp.push_back(num);
    }
    cin.ignore(256, '\n');
    int lf = tmp[0];
    int rf = tmp[1];
    if (tmp.size() == 2) {
      if (lf > rf) {
        int m1 = st.minimum(lf, n - 1);
        int m2 = st.minimum(0, rf);
        cout << min(m1, m2) << endl;
      } else {
        cout << st.minimum(lf, rf) << endl;
      }
    } else {
      int v = tmp[2];
      if (lf > rf) {
        st.increment(lf, n - 1, v);
        st.increment(0, rf, v);
      } else {
        st.increment(lf, rf, v);
      }
    }
  }
}
