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;
long long a[200001], tr[1000001], lazy[1000001];
void push(long long p) {
  tr[p << 1] += lazy[p];
  lazy[p << 1] += lazy[p];
  tr[(p << 1) | 1] += lazy[p];
  lazy[(p << 1) | 1] += lazy[p];
  lazy[p] = 0;
}
void build(long long p, long long l, long long r) {
  if (l > r) return;
  if (l == r) {
    tr[p] = a[l];
    return;
  }
  long long m = (l + r) >> 1;
  build(p << 1, l, m);
  build((p << 1) | 1, m + 1, r);
  tr[p] = min(tr[p << 1], tr[(p << 1) | 1]);
}
void update(long long p, long long l, long long r, long long s, long long e,
            long long val) {
  if (s > r or l > e or l > r or s > e) return;
  if (s <= l and e >= r) {
    tr[p] += val;
    lazy[p] += val;
    return;
  }
  push(p);
  long long m = (l + r) >> 1;
  update(p << 1, l, m, s, min(e, m), val);
  update((p << 1) | 1, m + 1, r, max(s, m + 1), e, val);
  tr[p] = min(tr[p << 1], tr[(p << 1) | 1]);
}
long long query(long long p, long long l, long long r, long long s,
                long long e) {
  if (s > r or l > e or l > r) return LLONG_MAX;
  if (s <= l and r <= e) return tr[p];
  push(p);
  long long m = (l + r) >> 1;
  return min(query(p << 1, l, m, s, min(e, m)),
             query((p << 1) | 1, m + 1, r, max(s, m + 1), e));
}
void solve() {
  memset(tr, 0, sizeof tr);
  memset(lazy, 0, sizeof lazy);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  build(1, 0, n - 1);
  long long q;
  cin >> q;
  string s;
  getline(cin, s);
  while (q--) {
    getline(cin, s);
    istringstream ss(s);
    vector<long long> v;
    long long x;
    while (ss >> x) v.push_back(x);
    if (v.size() == 2) {
      if (v[0] > v[1]) {
        long long x = query(1, 0, n - 1, 0, v[1]);
        long long y = query(1, 0, n - 1, v[0], n - 1);
        cout << min(x, y) << endl;
      } else
        cout << query(1, 0, n - 1, v[0], v[1]) << endl;
    } else {
      if (v[0] > v[1]) {
        update(1, 0, n - 1, 0, v[1], v[2]);
        update(1, 0, n - 1, v[0], n - 1, v[2]);
      } else
        update(1, 0, n - 1, v[0], v[1], v[2]);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t(1);
  for (long long i = 1; i <= t; solve(), i++)
    ;
  return 0;
}
