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 n;
vector<long long> v, lazy_st, st;
void build_st(long long id, long long l, long long r) {
  if (l == r) {
    lazy_st[id] = 0;
    st[id] = v[l];
    return;
  }
  long long mid = (l + r) / 2;
  build_st(2 * id + 1, l, mid);
  build_st(2 * id + 2, mid + 1, r);
  lazy_st[id] = 0;
  st[id] = min(st[2 * id + 1], st[2 * id + 2]);
}
void push(long long id) {
  lazy_st[2 * id + 1] += lazy_st[id];
  lazy_st[2 * id + 2] += lazy_st[id];
  st[2 * id + 1] += lazy_st[id];
  st[2 * id + 2] += lazy_st[id];
  lazy_st[id] = 0;
}
void update(long long low, long long high, long long l, long long r,
            long long id, long long addend) {
  if (l > high || r < low) return;
  if (l >= low && r <= high) {
    lazy_st[id] += addend;
    st[id] += addend;
    return;
  }
  push(id);
  long long mid = l + r;
  mid = mid / 2;
  update(low, high, l, mid, 2 * id + 1, addend);
  update(low, high, mid + 1, r, 2 * id + 2, addend);
  st[id] = min(st[2 * id + 1], st[2 * id + 2]);
}
long long get(long long low, long long high, long long id, long long l,
              long long r) {
  if (low > r || high < l) return 1e15;
  if (low <= l && high >= r) return st[id];
  push(id);
  long long mid = (l + r) / 2;
  return min(get(low, high, 2 * id + 1, l, mid),
             get(low, high, 2 * id + 2, mid + 1, r));
}
char buf[10000000];
void solve(int test) {
  gets(buf);
  sscanf(buf, "%d", &n);
  gets(buf);
  stringstream bs(buf);
  long long i, j;
  v.resize(n);
  for (i = 0; i < n; i++) {
    long long x;
    bs >> x;
    v[i] = x;
  }
  lazy_st.clear();
  st.clear();
  lazy_st.resize(4 * n);
  st.resize(4 * n, 0);
  build_st(0, 0, n - 1);
  long long m;
  gets(buf);
  stringstream ss(buf);
  ss >> m;
  long long tmp;
  ss >> tmp;
  for (i = 0; i < m; i++) {
    gets(buf);
    stringstream ss(buf);
    long long x, y, z;
    ss >> x >> y;
    if (ss >> z) {
      if (x <= y)
        update(x, y, 0, n - 1, 0, z);
      else
        update(x, n - 1, 0, n - 1, 0, z), update(0, y, 0, n - 1, 0, z);
    } else {
      long long res;
      if (x <= y)
        res = get(x, y, 0, 0, n - 1);
      else
        res = min(get(x, n - 1, 0, 0, n - 1), get(0, y, 0, 0, n - 1));
      cout << res << "\n";
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  for (int x = 1; x <= t; x++) {
    solve(x);
  }
  return 0;
}
