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 lazy[1000005];
long long tree[1000005];
int n, m;
int a[200005];
int l, r, x;
void build(int vl, int vr, int node) {
  if (vl == vr) {
    tree[node] = a[vl];
  } else {
    int mid = (vl + vr) / 2;
    build(vl, mid, node * 2);
    build(mid + 1, vr, node * 2 + 1);
    tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
  }
}
void addtree(int vl, int vr, int node) {
  if (vl > r || vr < l) {
    return;
  }
  if (vl >= l && vr <= r) {
    lazy[node] += x;
  } else {
    int mid = (vl + vr) / 2;
    addtree(vl, mid, node * 2);
    addtree(mid + 1, vr, node * 2 + 1);
    tree[node] = min(tree[node * 2] + lazy[node * 2],
                     tree[node * 2 + 1] + lazy[node * 2 + 1]);
  }
}
long long getmin(int vl, int vr, int node) {
  if (vl > r || vr < l) {
    return 1e12;
  }
  if (vl >= l && vr <= r) {
    return tree[node] + lazy[node];
  } else {
    int mid = (vl + vr) / 2;
    return min(getmin(vl, mid, node * 2), getmin(mid + 1, vr, node * 2 + 1)) +
           lazy[node];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  build(0, n - 1, 1);
  scanf("%d\n", &m);
  char c[1000];
  for (int i = 0; i < m; i++) {
    gets(c);
    int ll, rr;
    if (sscanf(c, "%d%d%d", &ll, &rr, &x) == 3) {
      if (rr >= ll) {
        l = ll;
        r = rr;
        addtree(0, n - 1, 1);
      } else {
        l = ll;
        r = n - 1;
        addtree(0, n - 1, 1);
        l = 0;
        r = rr;
        addtree(0, n - 1, 1);
      }
    } else {
      if (rr >= ll) {
        l = ll;
        r = rr;
        cout << getmin(0, n - 1, 1) << endl;
      } else {
        long long ans = 0;
        l = ll;
        r = n - 1;
        ans = getmin(0, n - 1, 1);
        l = 0;
        r = rr;
        ans = min(ans, getmin(0, n - 1, 1));
        cout << ans << endl;
      }
    }
  }
  return 0;
}
