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;
vector<long long> segt(4 * 200005, 0), lazy(4 * 200005, 0), ar(200005);
void build(long long ind, long long l, long long r) {
  if (l == r) {
    segt[ind] = ar[l];
    return;
  }
  long long mid = (l + r) >> 1;
  build(2 * ind, l, mid);
  build(2 * ind + 1, mid + 1, r);
  segt[ind] = min(segt[2 * ind], segt[2 * ind + 1]);
}
void update(long long ind, long long l, long long r, long long lq, long long rq,
            long long val) {
  if (l > r) return;
  if (lazy[ind]) {
    segt[ind] += lazy[ind];
    if (l != r) {
      lazy[2 * ind] += lazy[ind];
      lazy[2 * ind + 1] += lazy[ind];
    }
    lazy[ind] = 0;
  }
  if (r < lq || l > rq) return;
  if (lq <= l && r <= rq) {
    segt[ind] += val;
    if (l != r) {
      lazy[2 * ind] += val;
      lazy[2 * ind + 1] += val;
    }
    return;
  }
  long long mid = (l + r) >> 1;
  update(2 * ind, l, mid, lq, rq, val);
  update(2 * ind + 1, mid + 1, r, lq, rq, val);
  segt[ind] = min(segt[2 * ind], segt[2 * ind + 1]);
}
long long query(long long ind, long long l, long long r, long long lq,
                long long rq) {
  if (l > rq || r < lq || l > r) return INT_MAX;
  if (lazy[ind]) {
    segt[ind] += lazy[ind];
    if (l != r) {
      lazy[2 * ind] += lazy[ind];
      lazy[2 * ind + 1] += lazy[ind];
    }
    lazy[ind] = 0;
  }
  if (lq <= l && r <= rq) return segt[ind];
  long long mid = (l + r) >> 1;
  long long v1 = query(2 * ind, l, mid, lq, rq);
  long long v2 = query(2 * ind + 1, mid + 1, r, lq, rq);
  return min(v1, v2);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0; i < (long long)n; ++i) cin >> ar[i];
  build(1, 0, n - 1);
  long long q;
  cin >> q;
  cin.ignore();
  while (q--) {
    vector<long long> v;
    string temp;
    getline(cin, temp);
    istringstream iss(temp);
    long long in;
    while (iss >> in) {
      v.push_back(in);
    }
    if ((long long)v.size() == 2) {
      long long l = v[0], r = v[1];
      if (l > r) {
        long long v1 = query(1, 0, n - 1, l, n - 1);
        long long v2 = query(1, 0, n - 1, 0, r);
        cout << min(v1, v2) << endl;
      } else {
        cout << query(1, 0, n - 1, l, r) << endl;
      }
    } else {
      long long l = v[0], r = v[1], val = v[2];
      if (l > r) {
        update(1, 0, n - 1, l, n - 1, val);
        update(1, 0, n - 1, 0, r, val);
      } else {
        update(1, 0, n - 1, l, r, val);
      }
    }
  }
}
