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;
long long int seg[4 * 212345];
long long int lazy[4 * 212345];
long long int input[212345];
void build(int node, int l, int r) {
  if (l == r) {
    seg[node] = input[l];
    return;
  }
  int mid = (l + r) / 2;
  build(2 * node, l, mid);
  build(2 * node + 1, mid + 1, r);
  seg[node] = min(seg[2 * node], seg[2 * node + 1]);
  return;
}
void arrumaLazy(int node) {
  if (lazy[node] == 0) return;
  lazy[2 * node] += lazy[node];
  seg[2 * node] += lazy[node];
  lazy[2 * node + 1] += lazy[node];
  seg[2 * node + 1] += lazy[node];
  lazy[node] = 0;
}
void update(int node, int a, int b, int l, int r, long long int val) {
  if (b < l || a > r) return;
  if (l <= a && b <= r) {
    seg[node] += val;
    lazy[node] += val;
    return;
  }
  arrumaLazy(node);
  int mid = (a + b) / 2;
  update(2 * node, a, mid, l, r, val);
  update(2 * node + 1, mid + 1, b, l, r, val);
  seg[node] = min(seg[2 * node], seg[2 * node + 1]);
}
long long int query(int node, int a, int b, int l, int r) {
  if (b < l || a > r) return 0x3f3f3f3f3f3f3f3f;
  if (l <= a && b <= r) return seg[node];
  arrumaLazy(node);
  int mid = (a + b) / 2;
  long long int resp =
      min(query(2 * node, a, mid, l, r), query(2 * node + 1, mid + 1, b, l, r));
  return resp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> input[i + 1];
  build(1, 1, n);
  cin >> q;
  int a, b;
  long long int c;
  char ch;
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    a++;
    b++;
    cin.get(ch);
    if (ch == '\n') {
      if (a > b)
        cout << min(query(1, 1, n, a, n), query(1, 1, n, 1, b)) << "\n";
      else
        cout << query(1, 1, n, a, b) << "\n";
    } else {
      cin >> c;
      if (a > b) {
        update(1, 1, n, a, n, c);
        update(1, 1, n, 1, b, c);
      } else {
        update(1, 1, n, a, b, c);
      }
    }
  }
  return 0;
}
