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 st[800040];
int add[800040];
int arr[200020];
int N;
int i = 0;
int q;
char c;
char s[100];
int left(int p) { return p << 1; }
int right(int p) { return (p << 1) + 1; }
void build(int p, int L, int R) {
  if (L == R) {
    st[p] = arr[L];
  } else {
    build(left(p), L, (L + R) / 2);
    build(right(p), (L + R) / 2 + 1, R);
    int l = left(p);
    int r = right(p);
    st[p] = min(st[l], st[r]);
  }
}
void update(int p, int L, int R, int idx, int idy, int val) {
  if (idx > R || idy < L) return;
  if (idx <= L && R <= idy) {
    st[p] += val;
    add[p] += val;
  } else {
    add[2 * p] += add[p];
    add[2 * p + 1] += add[p];
    st[2 * p + 1] += add[p];
    st[2 * p] += add[p];
    add[p] = 0;
    update(left(p), L, (L + R) / 2, idx, idy, val);
    update(right(p), (L + R) / 2 + 1, R, idx, idy, val);
    int l = left(p);
    int r = right(p);
    st[p] = min(st[l], st[r]) + add[p];
  }
}
int rmq(int p, int L, int R, int i, int j) {
  if (i > R || j < L) return 1e9;
  if (L >= i && R <= j)
    return st[p];
  else {
    add[2 * p] += add[p];
    add[2 * p + 1] += add[p];
    st[2 * p + 1] += add[p];
    st[2 * p] += add[p];
    add[p] = 0;
    int x = min(rmq(left(p), L, (L + R) / 2, i, j),
                rmq(right(p), (L + R) / 2 + 1, R, i, j));
    return x + add[p];
  }
}
int main() {
  scanf("%d", &N);
  i = 0;
  for (; i < N; i++) scanf("%d", &arr[i]);
  build(1, 0, N - 1);
  scanf("%d", &q);
  scanf("%c", &c);
  for (int cc = 0; cc < q; cc++) {
    gets(s);
    int one, two, three;
    int x = sscanf(s, "%d%d%d", &one, &two, &three);
    if (x == 2) {
      if (two < one) {
        printf("%d\n",
               min(rmq(1, 0, N - 1, one, N - 1), rmq(1, 0, N - 1, 0, two)));
      } else
        printf("%d\n", rmq(1, 0, N - 1, one, two));
    } else if (x == 3) {
      if (two < one) {
        update(1, 0, N - 1, one, N - 1, three);
        update(1, 0, N - 1, 0, two, three);
      } else {
        update(1, 0, N - 1, one, two, three);
      }
    }
  }
  return 0;
}
