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;
const int MAXN = 2e5 + 11;
const double pi = acos(-1);
int siz;
struct node {
  int l, r;
  long long num;
  int ch[2];
  long long add;
} T[MAXN * 2];
int arr[MAXN], n;
void build(int o, int l, int r) {
  T[o].l = l;
  T[o].r = r;
  T[o].add = 0;
  if (l == r) {
    T[o].num = arr[l];
    return;
  }
  T[o].ch[0] = ++siz;
  build(T[o].ch[0], l, (l + r) >> 1);
  T[o].ch[1] = ++siz;
  build(T[o].ch[1], ((l + r) >> 1) + 1, r);
  T[o].num = min(T[T[o].ch[0]].num, T[T[o].ch[1]].num);
}
long long query(int o, int l, int r) {
  int nl = T[o].l, nr = T[o].r;
  if (min(r, nr) < max(l, nl)) return MAXN * MAXN;
  if (l <= nl && nr <= r) return T[o].num + T[o].add;
  return T[o].add + min(query(T[o].ch[0], l, r), query(T[o].ch[1], l, r));
}
void update(int o, int l, int r, long long num) {
  int nl = T[o].l, nr = T[o].r;
  if (min(r, nr) < max(l, nl)) return;
  if (l <= nl && nr <= r) {
    T[o].add += num;
    return;
  }
  update(T[o].ch[0], l, r, num);
  update(T[o].ch[1], l, r, num);
  T[o].num = min(T[T[o].ch[0]].num + T[T[o].ch[0]].add,
                 T[T[o].ch[1]].num + T[T[o].ch[1]].add);
}
int m;
int a, b;
long long c;
char q;
int main() {
  scanf("%d", &n);
  for (int(i) = (0); (i) < (n); (i)++) scanf("%d", arr + i + 1);
  siz = 1;
  build(1, 1, n);
  scanf("%d", &m);
  for (int(i) = (0); (i) < (m); (i)++) {
    scanf("%d%d", &a, &b);
    a++;
    b++;
    q = getchar();
    if (q == ' ') {
      scanf("%I64d", &c);
      if (a > b) {
        update(1, a, n, c);
        update(1, 1, b, c);
      } else {
        update(1, a, b, c);
      }
    } else {
      long long ans;
      if (a > b) {
        ans = min(query(1, a, n), query(1, 1, b));
      } else {
        ans = query(1, a, b);
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
