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;
int n, q, l, r;
long long a[200001], st[200001 << 2], delta[200001 << 2], v;
char c[100];
void push(int p, int L, int R) {
  if (delta[p]) {
    st[p] += delta[p];
    if (L != R) {
      int P = p << 1;
      delta[P] += delta[p];
      delta[P + 1] += delta[p];
    }
    delta[p] = 0;
  }
}
void pull(int p) {
  int P = p << 1;
  st[p] = min(st[P], st[P + 1]);
}
void build(int p, int L, int R) {
  delta[p] = 0;
  if (L == R) {
    st[p] = a[L];
    return;
  }
  int P = p << 1;
  int M = (L + R) >> 1;
  build(P, L, M);
  build(P + 1, M + 1, R);
  st[p] = min(st[P], st[P + 1]);
}
long long query(int p, int L, int R) {
  push(p, L, R);
  if (L > r || R < l) return LLONG_MAX;
  if (l <= L && R <= r) {
    return st[p];
  }
  int P = p << 1;
  int M = (L + R) >> 1;
  long long ans = min(query(P, L, M), query(P + 1, M + 1, R));
  pull(p);
  return ans;
}
void update(int p, int L, int R) {
  push(p, L, R);
  if (L > r || R < l) return;
  if (l <= L && R <= r) {
    delta[p] += v;
    push(p, L, R);
    return;
  }
  int P = p << 1;
  int M = (L + R) >> 1;
  update(P, L, M);
  update(P + 1, M + 1, R);
  pull(p);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  build(1, 0, n - 1);
  cin >> q;
  cin.ignore();
  while (q-- > 0) {
    cin.getline(c, 100);
    if (istringstream(c) >> l >> r >> v) {
      if (l <= r) {
        update(1, 0, n - 1);
      } else {
        int t = r;
        r = n - 1;
        update(1, 0, n - 1);
        r = t;
        l = 0;
        update(1, 0, n - 1);
      }
    } else {
      if (l <= r) {
        cout << query(1, 0, n - 1) << endl;
      } else {
        int t = r;
        r = n - 1;
        long long ans = query(1, 0, n - 1);
        r = t;
        l = 0;
        ans = min(ans, query(1, 0, n - 1));
        cout << ans << endl;
      }
    }
  }
}
