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;
struct info {
  long long sum, prop;
} tree[200005 * 3];
void update(long long node, long long start, long long end, long long i,
            long long j, long long x) {
  if (start > j || end < i) return;
  if (start >= i && end <= j) {
    tree[node].sum += x;
    tree[node].prop += x;
    return;
  }
  long long left = 2 * node;
  long long right = 2 * node + 1;
  long long mid = (start + end) / 2;
  update(left, start, mid, i, j, x);
  update(right, mid + 1, end, i, j, x);
  tree[node].sum =
      min(tree[left].sum + tree[node].prop, tree[right].sum + tree[node].prop);
}
long long query(long long node, long long start, long long end, long long i,
                long long j, long long carry = 0) {
  if (start > j || end < i) return 100000000000000000;
  if (start >= i && end <= j) return tree[node].sum + carry;
  long long left = 2 * node;
  long long right = 2 * node + 1;
  long long mid = (start + end) / 2;
  long long q1 = query(left, start, mid, i, j, carry + tree[node].prop);
  long long q2 = query(right, mid + 1, end, i, j, carry + tree[node].prop);
  return min(q1, q2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, i, j, k, m, x, l, r;
  cin >> n;
  long long ara[n + 4];
  for (i = 1; i <= n; i++) {
    cin >> ara[i];
    update(1, 1, n, i, i, ara[i]);
  }
  cin >> m;
  long long input[10];
  input[2] = 0;
  cin.ignore();
  for (i = 0; i < m; i++) {
    string str;
    j = 0;
    getline(cin, str);
    stringstream stream(str);
    while (stream >> x) input[j++] = x;
    l = input[0] + 1;
    r = input[1] + 1;
    x = input[2];
    if (j == 2) {
      if (l > r)
        cout << min(query(1, 1, n, l, n), query(1, 1, n, 1, r)) << "\n";
      else
        cout << query(1, 1, n, l, r) << "\n";
    } else {
      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);
    }
  }
}
