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 double eps = 1e-10;
const int inf = 1 << 28;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long In() {
  long long x;
  cin >> x;
  return x;
}
double inreal() {
  double x;
  scanf("%lf", &x);
  return x;
}
string instr() {
  char buf[1001];
  scanf("%s", buf);
  return (string)buf;
}
struct segment_tree {
  int lf_size, size;
  vector<long long> dat;
  vector<long long> inc;
  long long u;
  segment_tree(){};
  segment_tree(int n, long long unit) { init(n, unit); }
  void init(int n, long long unit) {
    u = unit;
    for (lf_size = 1; lf_size < n; lf_size <<= 1) continue;
    size = lf_size << 1;
    dat.resize(size, u);
    inc.resize(size, 0);
  }
  void clear() {
    for (int i = 0; i < dat.size(); i++) dat[i] = u;
  }
  int lc(int p) { return p << 1; }
  int rc(int p) { return p << 1 | 1; }
  int llc(int l, int r) { return l; }
  int rlc(int l, int r) { return l + r >> 1; }
  int lrc(int l, int r) { return (l + r >> 1) + 1; }
  int rrc(int l, int r) { return r; }
  int isct(int a, int b, int lt, int rg) {
    if (a <= lt and rg <= b) return 1;
    if (rg < a or b < lt) return 0;
    return 2;
  }
  long long up_mrg(const long long& a, const long long& b) {
    if (a > b) return b;
    return a;
  }
  void update(int pos, long long val) {
    for (pos = pos + lf_size; pos > 0; pos >>= 1) {
      if (pos >= lf_size)
        dat[pos] = val;
      else
        dat[pos] = up_mrg(dat[lc(pos)], dat[rc(pos)]);
    }
  }
  void apr(int a, int b, int x, int p, int lt, int rg) {
    int is = isct(a, b, lt, rg);
    if (is == 0) return;
    if (is == 1) {
      dat[p] += x;
      inc[p] += x;
    }
    if (is == 2) {
      apr(a, b, x, lc(p), lt, rlc(lt, rg));
      apr(a, b, x, rc(p), lrc(lt, rg), rg);
      dat[p] = up_mrg(dat[lc(p)], dat[rc(p)]) + inc[p];
    }
  }
  void range_add(int a, int b, int x) { apr(a, b, x, 1, 0, lf_size - 1); }
  long long gpr(int a, int b, int p, int lt, int rg) {
    int is = isct(a, b, lt, rg);
    if (is == 0) {
      return u;
    }
    if (is == 1) {
      return dat[p];
    }
    if (is == 2) {
      return inc[p] + up_mrg(gpr(a, b, lc(p), lt, rlc(lt, rg)),
                             gpr(a, b, rc(p), lrc(lt, rg), rg));
    }
  }
  long long get(int bgn, int end) { return gpr(bgn, end, 1, 0, lf_size - 1); }
  void debug() {
    for (int i = 1; i <= lf_size; i <<= 1) {
      for (int j = i, k = 0; k < i; k++, j++) {
        cout << '(' << dat[j] << ',' << inc[j] << ')' << ' ';
      }
      puts("");
    }
  }
  void print_leaf() {
    for (int i = lf_size; i < 2 * lf_size; i++) {
      if (dat[i] == u)
        cout << "I ";
      else
        cout << dat[i] << ' ';
    }
    puts("");
  }
};
const long long INF = (long long)pow(10., 17.);
int main() {
  int i, j, k, n = in();
  segment_tree sgt(n, INF);
  for ((i) = (0); (i) < (int)(n); (i)++) sgt.update(i, in());
  int q = in();
  for ((i) = (0); (i) < (int)(q); (i)++) {
    string buf;
    getline(cin, buf);
    stringstream ss(buf);
    vector<int> qe;
    long long t;
    while (ss >> t) qe.push_back(t);
    if (qe.size() == 2) {
      if (qe[0] > qe[1]) {
        cout << min(sgt.get(0, qe[1]), sgt.get(qe[0], n - 1)) << endl;
      } else {
        cout << sgt.get(qe[0], qe[1]) << endl;
      }
    } else if (qe.size() == 3) {
      if (qe[0] > qe[1]) {
        sgt.range_add(0, qe[1], qe[2]);
        sgt.range_add(qe[0], n - 1, qe[2]);
      } else {
        sgt.range_add(qe[0], qe[1], qe[2]);
      }
    } else {
      i--;
    }
  }
  return 0;
}
