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 tree[200000 * 4];
long long lazy[200000 * 4];
int v[200000];
int n;
void build_tree(int node, int a, int b) {
  if (a > b) return;
  if (a == b) {
    tree[node] = v[a];
    return;
  }
  build_tree(node * 2, a, (a + b) / 2);
  build_tree(node * 2 + 1, 1 + (a + b) / 2, b);
  tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
}
void update_lazy(int node, int a, int b) {
  tree[node] += lazy[node];
  if (a != b) {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
  }
  lazy[node] = 0;
}
void update_tree(int node, int a, int b, int i, int j, long long value) {
  if (lazy[node] != 0) update_lazy(node, a, b);
  if (a > b || a > j || b < i) return;
  if (a >= i && b <= j) {
    tree[node] += value;
    if (a != b) {
      lazy[node * 2] += value;
      lazy[node * 2 + 1] += value;
    }
    return;
  }
  update_tree(node * 2, a, (a + b) / 2, i, j, value);
  update_tree(1 + node * 2, 1 + (a + b) / 2, b, i, j, value);
  tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
}
long long query_tree(int node, int a, int b, int i, int j) {
  if (a > b || a > j || b < i) return 2100000000;
  if (lazy[node] != 0) update_lazy(node, a, b);
  if (a >= i && b <= j) return tree[node];
  long long q1 = query_tree(node * 2, a, (a + b) / 2, i, j);
  long long q2 = query_tree(1 + node * 2, 1 + (a + b) / 2, b, i, j);
  return min(q1, q2);
}
void IntervalTree() {
  n = 200000;
  int s = 2 * pow(2, ceil(log2(200000)));
  build_tree(1, 0, n - 1);
}
void update(int idx1, int idx2, long long add) {
  update_tree(1, 0, n - 1, idx1, idx2, add);
}
long long query(int idx1, int idx2) {
  return query_tree(1, 0, n - 1, idx1, idx2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q, t1, t2, t3;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> v[i];
  cin >> q;
  IntervalTree();
  while (q--) {
    cin >> t1 >> t2;
    if (cin.peek() == '\n') {
      if (t1 <= t2)
        cout << query(t1, t2) << endl;
      else
        cout << min(query(0, t2), query(t1, n - 1)) << endl;
    } else {
      cin >> t3;
      if (t1 <= t2)
        update(t1, t2, t3);
      else
        update(0, t2, t3), update(t1, n - 1, t3);
    }
  }
  return 0;
}
