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;
long long tree[1 << 19];
long long lazy[1 << 19];
int arr[200005];
void build_tree(int node, int L, int R) {
  if (L == R)
    tree[node] = arr[L];
  else {
    build_tree(node << 1, L, (L + R) >> 1);
    build_tree(node << 1 | 1, ((L + R) >> 1) + 1, R);
    tree[node] = min(tree[node << 1], tree[node << 1 | 1]);
  }
}
void propagate(int node) {
  if (lazy[node]) {
    lazy[node << 1] += lazy[node];
    lazy[node << 1 | 1] += lazy[node];
    tree[node << 1] += lazy[node];
    tree[node << 1 | 1] += lazy[node];
    lazy[node] = 0;
  }
}
void update(int node, int L, int R, int i, int j, int v) {
  if (L > j || R < i) return;
  if (L >= i && R <= j) {
    lazy[node] += v;
    tree[node] += v;
    return;
  }
  propagate(node);
  update(node << 1, L, (L + R) >> 1, i, j, v);
  update(node << 1 | 1, ((L + R) >> 1) + 1, R, i, j, v);
  tree[node] = min(tree[node << 1], tree[node << 1 | 1]);
}
long long query(int node, int L, int R, int i, int j) {
  if (L > j || R < i) return (1e18);
  if (L >= i && R <= j) return tree[node];
  propagate(node);
  return min(query(node << 1, L, (L + R) >> 1, i, j),
             query(node << 1 | 1, ((L + R) >> 1) + 1, R, i, j));
}
int main() {
  char t;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  build_tree(1, 0, n - 1);
  int q;
  scanf("%d", &q);
  while (q) {
    int a, b, x;
    scanf("%d %d%c", &a, &b, &t);
    if (t == ' ') {
      scanf("%d\n", &x);
      if (a <= b)
        update(1, 0, n - 1, a, b, x);
      else {
        update(1, 0, n - 1, a, n - 1, x);
        update(1, 0, n - 1, 0, b, x);
      }
    } else {
      if (a <= b)
        printf("%I64d\n", query(1, 0, n - 1, a, b));
      else
        printf("%I64d\n",
               min(query(1, 0, n - 1, a, n - 1), query(1, 0, n - 1, 0, b)));
    }
    q--;
  }
  return 0;
}
