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;
const int N = 2e5 + 10;
const long long oo = 1e15;
long long IT[4 * N], a[N], lazy[4 * N];
int n;
long long build(long long IT[], int p, long long a[], int l, int r) {
  if (l == r) return IT[p] = a[l];
  int mid = (l + r) / 2;
  return IT[p] = min(build(IT, 2 * p, a, l, mid),
                     build(IT, 2 * p + 1, a, mid + 1, r));
}
void lazyDown(long long IT[], int p) {
  if (2 * p + 1 >= 4 * n) return;
  lazy[2 * p] += lazy[p];
  lazy[2 * p + 1] += lazy[p];
  IT[2 * p] += lazy[p];
  IT[2 * p + 1] += lazy[p];
  lazy[p] = 0;
}
long long update(long long IT[], int p, int l, int r, int L, int R,
                 long long val) {
  if (r < L || R < l || r < l || R < L) return IT[p];
  lazyDown(IT, p);
  if (L <= l && r <= R) {
    lazy[p] += val;
    return IT[p] = IT[p] + val;
  }
  int mid = (l + r) / 2;
  return IT[p] = min(update(IT, 2 * p, l, mid, L, R, val),
                     update(IT, 2 * p + 1, mid + 1, r, L, R, val));
}
long long rmq(long long IT[], int p, int l, int r, int L, int R) {
  if (r < L || R < l || r < l || R < L) return oo;
  lazyDown(IT, p);
  if (L <= l && r <= R)
    return IT[p];
  else {
    int mid = (l + r) / 2;
    return min(rmq(IT, 2 * p, l, mid, L, R),
               rmq(IT, 2 * p + 1, mid + 1, r, L, R));
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  build(IT, 1, a, 0, n - 1);
  int q;
  cin >> q;
  cin.ignore();
  while (q--) {
    string line;
    getline(cin, line);
    stringstream ss(line);
    vector<int> v;
    int x;
    while (ss >> x) v.push_back(x);
    int l = v[0], r = v[1];
    if (v.size() == 2) {
      if (l <= r)
        printf("%I64d\n", rmq(IT, 1, 0, n - 1, l, r));
      else
        printf("%I64d\n",
               min(rmq(IT, 1, 0, n - 1, l, n - 1), rmq(IT, 1, 0, n - 1, 0, r)));
    } else {
      if (l <= r)
        update(IT, 1, 0, n - 1, l, r, v[2]);
      else
        update(IT, 1, 0, n - 1, 0, r, v[2]),
            update(IT, 1, 0, n - 1, l, n - 1, v[2]);
    }
  }
}
