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>
const int INFI = (1 << 29);
const long long INFL = (1LL << 62);
using namespace std;
long long n, q, a, b, k;
vector<long long> v, st, lazy;
long long left(const long long &x) { return (x << 1LL); }
long long right(const long long &x) { return ((x << 1LL) + 1LL); }
vector<long long> leerInput(const string &in) {
  bool neg = false;
  long long vin = 0;
  vector<long long> inpt;
  for (char i : in) {
    if (i == ' ') {
      if (neg)
        inpt.push_back(vin * (-1));
      else
        inpt.push_back(vin);
      vin = 0;
      neg = false;
    } else if (i == '-')
      neg = true;
    else
      vin = ((vin * 10) + (i - '0'));
  }
  if (neg)
    inpt.push_back(vin * (-1));
  else
    inpt.push_back(vin);
  return inpt;
}
void build(long long p, long long L, long long R) {
  if (L == R)
    st[p] = v[L];
  else {
    build(left(p), L, ((L + R) / 2));
    build(right(p), (((L + R) / 2) + 1), R);
    long long r1 = st[left(p)], r2 = st[right(p)];
    st[p] = min(r1, r2);
  }
}
long long RMQ(long long p, long long L, long long R, long long i, long long j) {
  if (lazy[p] != 0) {
    st[p] += lazy[p];
    if (L != R) {
      lazy[left(p)] += lazy[p];
      lazy[right(p)] += lazy[p];
    }
    lazy[p] = 0;
  }
  if ((L > j) || (R < i)) return INFL;
  if ((L >= i) && (R <= j)) return st[p];
  long long r1 = RMQ(left(p), L, ((L + R) / 2), i, j);
  long long r2 = RMQ(right(p), (((L + R) / 2) + 1), R, i, j);
  return min(r1, r2);
}
void update(long long p, long long L, long long R, long long i, long long j,
            long long val) {
  if (lazy[p] != 0) {
    st[p] += lazy[p];
    if (L != R) {
      lazy[left(p)] += lazy[p];
      lazy[right(p)] += lazy[p];
    }
    lazy[p] = 0;
  }
  if ((L > j) || (R < i)) return;
  if ((L >= i) && (R <= j)) {
    st[p] += val;
    if (L != R) {
      lazy[left(p)] += val;
      lazy[right(p)] += val;
    }
    return;
  }
  update(left(p), L, ((L + R) / 2), i, j, val);
  update(right(p), (((L + R) / 2) + 1), R, i, j, val);
  long long r1 = st[left(p)], r2 = st[right(p)];
  st[p] = min(r1, r2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string in;
  cin >> n;
  v.resize(n);
  st = lazy = vector<long long>(((n * 4) + 10), 0);
  for (long long i = 0; i < n; i++) cin >> v[i];
  build(1, 0, (n - 1));
  cin >> q;
  cin.ignore();
  while (q--) {
    getline(cin, in);
    vector<long long> input = leerInput(in);
    a = input[0];
    b = input[1];
    if (int(input.size()) == 3) {
      k = input[2];
      if (a <= b) {
        update(1, 0, (n - 1), a, b, k);
      } else {
        update(1, 0, (n - 1), a, (n - 1), k);
        update(1, 0, (n - 1), 0, b, k);
      }
    } else {
      if (a <= b)
        cout << RMQ(1, 0, (n - 1), a, b) << "\n";
      else
        cout << min(RMQ(1, 0, (n - 1), a, (n - 1)), RMQ(1, 0, (n - 1), 0, b))
             << "\n";
    }
  }
  return 0;
}
