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 long long inf = 1e15;
long long n, a[200001], m, t[200001 * 4], add[200001 * 4];
void build(int v, int tl, int tr) {
  if (tl == tr) {
    t[v] = a[tl];
    return;
  }
  int tm = (tl + tr) >> 1;
  build(v + v, tl, tm);
  build(v + v + 1, tm + 1, tr);
  t[v] = min(t[v + v], t[v + v + 1]);
}
void push(int v, int tl, int tr) {
  t[v] += add[v];
  if (tr != tl) {
    add[v + v] += add[v];
    add[v + v + 1] += add[v];
  }
  add[v] = 0;
}
void update(int v, int tl, int tr, int l, int r, int x) {
  push(v, tl, tr);
  if (l > r || tl > r || tr < l) {
    return;
  }
  if (l <= tl && tr <= r) {
    add[v] += x;
    push(v, tl, tr);
    return;
  }
  int tm = (tl + tr) >> 1;
  update(v + v, tl, tm, l, r, x);
  update(v + v + 1, tm + 1, tr, l, r, x);
  t[v] = min(t[v + v], t[v + v + 1]);
}
long long getmin(int v, int tl, int tr, int l, int r) {
  push(v, tl, tr);
  if (l > r || tl > r || tr < l) {
    return inf;
  }
  if (l <= tl && tr <= r) {
    return t[v];
  }
  int tm = (tl + tr) >> 1;
  return min(getmin(v + v, tl, tm, l, r), getmin(v + v + 1, tm + 1, tr, l, r));
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  build(1, 1, n);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int l, r, x;
    char c;
    cin >> l >> r;
    l++;
    r++;
    c = cin.get();
    if (c == ' ') {
      cin >> x;
      if (l > r) {
        update(1, 1, n, l, n, x);
        update(1, 1, n, 1, r, x);
      } else {
        update(1, 1, n, l, r, x);
      }
    } else {
      if (l > r) {
        cout << min(getmin(1, 1, n, l, n), getmin(1, 1, n, 1, r)) << '\n';
      } else {
        cout << getmin(1, 1, n, l, r) << '\n';
      }
    }
  }
  return 0;
}
