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 sum[5000005];
long long col[5000005];
void pushup(int rt) { sum[rt] = min(sum[rt << 1], sum[rt << 1 | 1]); }
void pushdown(int rt, int m) {
  if (col[rt]) {
    col[rt << 1] += col[rt];
    col[rt << 1 | 1] += col[rt];
    sum[rt << 1] += col[rt];
    sum[rt << 1 | 1] += col[rt];
    col[rt] = 0;
  }
}
void build(int l, int r, int rt) {
  col[rt] = 0;
  if (l == r) {
    scanf("%I64d", &sum[rt]);
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, rt << 1);
  build(m + 1, r, rt << 1 | 1);
  pushup(rt);
}
void update(int L, int R, int v, int l, int r, int rt) {
  if (L <= l && r <= R) {
    col[rt] += v;
    sum[rt] += v;
    return;
  }
  pushdown(rt, r - l + 1);
  int m = (l + r) >> 1;
  if (L <= m) update(L, R, v, l, m, rt << 1);
  if (R > m) update(L, R, v, m + 1, r, rt << 1 | 1);
  pushup(rt);
}
long long query(int L, int R, int l, int r, int rt) {
  if (L <= l && r <= R) return sum[rt];
  pushdown(rt, r - l + 1);
  int m = (l + r) >> 1;
  long long ret = INT_MAX;
  if (L <= m) ret = min(ret, query(L, R, l, m, rt << 1));
  if (R > m) ret = min(ret, query(L, R, m + 1, r, rt << 1 | 1));
  return ret;
}
int main() {
  int n, m, a, b, c;
  char op;
  scanf("%d", &n);
  build(1, n, 1);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%c", &a, &b, &op);
    a++;
    b++;
    if (a <= b) {
      if (op == ' ') {
        scanf("%d", &c);
        if (c == 0) continue;
        update(a, b, c, 1, n, 1);
      } else
        printf("%I64d\n", query(a, b, 1, n, 1));
    } else {
      if (op == ' ') {
        scanf("%d", &c);
        if (c == 0) continue;
        update(a, n, c, 1, n, 1);
        update(1, b, c, 1, n, 1);
      } else
        printf("%I64d\n", min(query(a, n, 1, n, 1), query(1, b, 1, n, 1)));
    }
  }
  return 0;
}
