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 modpow(long long b, long long e, long long mod) {
  long long ans = 1;
  for (; e; b = b * b % mod, e /= 2) {
    if (e & 1) ans = ans * b % mod;
  }
  return ans;
}
template <class T>
struct lazy_seg {
 public:
  vector<T> st, lazy;
  lazy_seg(int n) { st.resize(4 * n + 1, 0), lazy.resize(4 * n + 1, 0); }
  lazy_seg() = default;
  void push(int l, int r, int curr) {
    if (lazy[curr] != 0) {
      st[curr] += lazy[curr];
      if (l != r)
        lazy[2 * curr] += lazy[curr], lazy[2 * curr + 1] += lazy[curr];
      lazy[curr] = 0;
    }
  }
  void pull(int l, int r, int curr) {
    push(l, r, curr);
    int mid = l + (r - l) / 2;
    if (l != r) push(l, mid, 2 * curr), push(mid + 1, r, 2 * curr + 1);
    st[curr] = min(st[2 * curr], st[2 * curr + 1]);
  }
  void upd(int x, int y, T v, int l, int r, int curr) {
    int mid = (l + r) / 2;
    push(l, r, curr);
    if (l == x && r == y) {
      lazy[curr] += v;
      push(l, r, curr);
      return;
    }
    if (y <= mid)
      upd(x, y, v, l, mid, 2 * curr);
    else if (x > mid)
      upd(x, y, v, mid + 1, r, 2 * curr + 1);
    else
      upd(x, mid, v, l, mid, 2 * curr),
          upd(mid + 1, y, v, mid + 1, r, 2 * curr + 1);
    pull(l, r, curr);
  }
  T qry(int x, int y, int l, int r, int curr) {
    int mid = (l + r) / 2;
    push(l, r, curr);
    if (l == x && r == y) return st[curr];
    if (y <= mid)
      return qry(x, y, l, mid, 2 * curr);
    else if (x > mid)
      return qry(x, y, mid + 1, r, 2 * curr + 1);
    return min(qry(x, mid, l, mid, 2 * curr),
               qry(mid + 1, y, mid + 1, r, 2 * curr + 1));
  }
  void build(int l, int r, int curr, const vector<int>& v) {
    int mid = (l + r) / 2;
    if (l == r) {
      st[curr] = v[l];
      return;
    }
    build(l, mid, 2 * curr, v);
    build(mid + 1, r, 2 * curr + 1, v);
    st[curr] = min(st[2 * curr], st[2 * curr + 1]);
  }
};
int32_t main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < (n); ++i) cin >> v[i];
  lazy_seg<long long> seg(n);
  seg.build(0, n - 1, 1, v);
  int m;
  cin >> m;
  while (m--) {
    int l, r;
    char c;
    scanf("%d%d%c", &l, &r, &c);
    if (c == '\n') {
      long long p = INT_MAX;
      if (l <= r) {
        cout << seg.qry(l, r, 0, n - 1, 1) << endl;
      } else {
        p = min(p, seg.qry(l, n - 1, 0, n - 1, 1));
        p = min(p, seg.qry(0, r, 0, n - 1, 1));
        cout << p << endl;
      }
    } else {
      int val;
      cin >> val;
      if (l <= r) {
        seg.upd(l, r, val, 0, n - 1, 1);
      } else {
        seg.upd(l, n - 1, val, 0, n - 1, 1);
        seg.upd(0, r, val, 0, n - 1, 1);
      }
    }
  }
}
