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;
template <typename Arg1, typename Arg2>
ostream& operator<<(ostream& out, const pair<Arg1, Arg2>& x) {
  return out << "(" << x.first << "," << x.second << ")";
}
template <typename Arg1>
ostream& operator<<(ostream& out, const vector<Arg1>& a) {
  out << "[";
  for (const auto& x : a) out << x << ",";
  return out << "]";
}
template <typename Arg1>
ostream& operator<<(ostream& out, const set<Arg1>& a) {
  out << "[";
  for (const auto& x : a) out << x << ",";
  return out << "]";
}
template <typename Arg1, typename Arg2>
ostream& operator<<(ostream& out, const map<Arg1, Arg2>& a) {
  out << "[";
  for (const auto& x : a) out << x << ",";
  return out << "]";
}
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << " ] " << endl;
}
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args) {
  const string name = names.substr(0, names.find(','));
  cerr << name << " : " << arg1 << " | ";
  __trace__(names.substr(1 + (int)name.size()), args...);
}
clock_t time_p = clock();
void time_taken() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
const long long mod = 1e9 + 7;
const long long INF = 1e18;
const int maxn = 4e5 + 5;
vector<int> a(maxn);
vector<long long> mn(4 * maxn);
vector<long long> lzy(4 * maxn);
void build(int v, int l, int r) {
  if (l > r) return;
  if (l == r) {
    mn[v] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(2 * v, l, mid);
  build(2 * v + 1, mid + 1, r);
  mn[v] = min(mn[2 * v], mn[2 * v + 1]);
}
long long get(int v, int l, int r, int ql, int qr) {
  if (ql > qr) return INF;
  if (ql > r or qr < l) return INF;
  if (l >= ql and r <= qr) return mn[v];
  int mid = (l + r) >> 1;
  for (int x : {2 * v, 2 * v + 1}) {
    mn[x] += lzy[v];
    lzy[x] += lzy[v];
  }
  lzy[v] = 0;
  return min(get(2 * v, l, mid, ql, qr), get(2 * v + 1, mid + 1, r, ql, qr));
}
void upd(int v, int l, int r, int ql, int qr, int val) {
  if (ql > qr) return;
  if (ql > r or qr < l) return;
  if (l >= ql and r <= qr) {
    mn[v] += val;
    lzy[v] += val;
    return;
  }
  int mid = (l + r) >> 1;
  for (int x : {2 * v, 2 * v + 1}) {
    mn[x] += lzy[v];
    lzy[x] += lzy[v];
  }
  lzy[v] = 0;
  mn[v] = mod;
  upd(2 * v, l, mid, ql, qr, val);
  upd(2 * v + 1, mid + 1, r, ql, qr, val);
  for (int x : {2 * v, 2 * v + 1}) {
    mn[v] = min(mn[v], mn[x]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(12);
  cout << fixed;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = n; i <= 2 * n - 1; i++) {
    a[i] = a[i % n];
  }
  build(1, 0, 2 * n - 1);
  int q;
  cin >> q;
  string foo;
  getline(cin, foo);
  while (q--) {
    string s;
    getline(cin, s);
    string ls = "", rs = "", vs = "";
    vector<int> ind;
    for (int i = 0; i < (int)s.size(); i++) {
      if (s[i] == ' ') ind.push_back(i);
    }
    if ((int)ind.size() == 1) {
      int m = (int)s.size();
      ls = s.substr(0, ind[0]);
      int l = stoi(ls);
      rs = s.substr(ind[0] + 1, m - (ind[0] + 1));
      int r = stoi(rs);
      if (l > r) r += n;
      cout << get(1, 0, 2 * n - 1, l, r) << '\n';
    } else {
      int m = (int)s.size();
      ls = s.substr(0, ind[0]);
      int l = stoi(ls);
      rs = s.substr(ind[0] + 1, ind[1] - (ind[0] + 1));
      int r = stoi(rs);
      vs = s.substr(ind[1] + 1, m - (ind[1] + 1));
      int val = stoi(vs);
      if (l > r) {
        upd(1, 0, 2 * n - 1, 0, r, val);
        upd(1, 0, 2 * n - 1, l, r + n, val);
        upd(1, 0, 2 * n - 1, l + n, 2 * n - 1, val);
      } else {
        upd(1, 0, 2 * n - 1, l, r, val);
        upd(1, 0, 2 * n - 1, l + n, r + n, val);
      }
    }
  }
  time_taken();
  return 0;
}
