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 _ {
  _() { ios_base::sync_with_stdio(0); }
} _;
template <class T>
void PV(T a, T b) {
  while (a != b) cout << *a++, cout << (a != b ? " " : "\n");
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
const int inf = 0x3f3f3f3f;
const int mod = int(1e9) + 7;
const int N = 2 * 111111;
long long val[4 * N];
long long lazy[4 * N];
void add(int L, int R, long long c, int l, int r, int rt) {
  if (L <= l && r <= R) {
    val[rt] += c;
    lazy[rt] += c;
    return;
  }
  if (lazy[rt] != 0) {
    lazy[2 * rt] += lazy[rt];
    lazy[2 * rt + 1] += lazy[rt];
    val[2 * rt] += lazy[rt];
    val[2 * rt + 1] += lazy[rt];
    lazy[rt] = 0;
  }
  int m = (l + r) / 2;
  if (L <= m) add(L, R, c, l, m, 2 * rt);
  if (R > m) add(L, R, c, m + 1, r, 2 * rt + 1);
  val[rt] = min(val[2 * rt], val[2 * rt + 1]);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) {
    return val[rt];
  }
  if (lazy[rt] != 0) {
    lazy[2 * rt] += lazy[rt];
    lazy[2 * rt + 1] += lazy[rt];
    val[2 * rt] += lazy[rt];
    val[2 * rt + 1] += lazy[rt];
    lazy[rt] = 0;
  }
  int m = (l + r) / 2;
  long long res = 1LL << 60;
  if (L <= m) chmin(res, query(L, R, l, m, 2 * rt));
  if (R > m) chmin(res, query(L, R, m + 1, r, 2 * rt + 1));
  val[rt] = min(val[2 * rt], val[2 * rt + 1]);
  return res;
}
int n, q;
long long d[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    add(i, i, d[i], 1, n, 1);
  }
  cin >> q;
  cin.get();
  while (q--) {
    string s;
    getline(cin, s);
    int space = count((s).begin(), (s).end(), ' ');
    istringstream ss(s);
    int l, r, v;
    ss >> l >> r;
    l++, r++;
    if (space == 2) {
      ss >> v;
      if (l <= r)
        add(l, r, v, 1, n, 1);
      else
        add(1, r, v, 1, n, 1), add(l, n, v, 1, n, 1);
    } else {
      if (l <= r)
        cout << query(l, r, 1, n, 1) << endl;
      else
        cout << min(query(1, r, 1, n, 1), query(l, n, 1, n, 1)) << endl;
    }
  }
  return 0;
}
