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 int N = 2e5 + 5;
const long long INF = 1e14;
int n, q;
long long a[N], st[N << 2], lazy[N << 2];
void build(int p, int l, int r) {
  if (l == r) {
    st[p] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(p * 2, l, mid);
  build(p * 2 + 1, mid + 1, r);
  st[p] = min(st[p * 2], st[p * 2 + 1]);
}
void push(int p, int l, int r) {
  if (lazy[p] == 0) return;
  st[p] += lazy[p];
  if (l != r) {
    lazy[p * 2] += lazy[p];
    lazy[p * 2 + 1] += lazy[p];
  }
  lazy[p] = 0;
}
void update(int p, int l, int r, int S, int E, long long v) {
  push(p, l, r);
  if (l >= S && r <= E) {
    lazy[p] += v;
    push(p, l, r);
    return;
  }
  if (E < l || S > r) return;
  int mid = (l + r) >> 1;
  update(p * 2, l, mid, S, E, v);
  update(p * 2 + 1, mid + 1, r, S, E, v);
  st[p] = min(st[p * 2], st[p * 2 + 1]);
}
long long rmq(int p, int l, int r, int S, int E) {
  push(p, l, r);
  if (l >= S && r <= E) return st[p];
  if (E < l || S > r) return INF;
  int mid = (l + r) >> 1;
  return min(rmq(p * 2, l, mid, S, E), rmq(p * 2 + 1, mid + 1, r, S, E));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n);
  cin >> q;
  string s;
  getline(cin, s);
  while (q--) {
    getline(cin, s);
    stringstream ss(s);
    vector<int> tmp;
    int x;
    while (ss >> x) {
      tmp.push_back(x);
    }
    int l = tmp[0] + 1;
    int r = tmp[1] + 1;
    if (tmp.size() == 2) {
      if (l > r) {
        cout << min(rmq(1, 1, n, l, n), rmq(1, 1, n, 1, r)) << endl;
      } else {
        cout << rmq(1, 1, n, l, r) << endl;
      }
    } else {
      long long v = tmp[2] * 1ll;
      if (l > r) {
        update(1, 1, n, l, n, v);
        update(1, 1, n, 1, r, v);
      } else {
        update(1, 1, n, l, r, v);
      }
    }
  }
}
