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, t[400001], d[200001], h;
void apply(int p, int value) {
  t[p] += value;
  if (p < n) d[p] += value;
}
void build(int p) {
  while (p > 1) {
    p >>= 1;
    t[p] = min(t[p << 1], t[p << 1 | 1]) + d[p];
  }
}
void push(int p) {
  for (int s = h; s > 0; --s) {
    int i = p >> s;
    if (d[i] != 0) {
      apply(i << 1, d[i]);
      apply(i << 1 | 1, d[i]);
      d[i] = 0;
    }
  }
}
void inc(int l, int r, int value) {
  l += n, r += n;
  int l0 = l, r0 = r;
  for (; l < r; l >>= 1, r >>= 1) {
    if (l & 1) apply(l++, value);
    if (r & 1) apply(--r, value);
  }
  build(l0);
  build(r0 - 1);
}
int query(int l, int r) {
  l += n, r += n;
  push(l);
  push(r);
  int res = 2e9;
  for (; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res = min(res, t[l++]);
    if (r & 1) res = min(t[--r], res);
  }
  return res;
}
int main() {
  scanf("%d", &n);
  h = sizeof(int) * 8 - __builtin_clz(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    inc(i, i + 1, tmp);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    char c;
    scanf("%c", &c);
    if (c == 13 || c == 10) {
      if (t1 <= t2)
        printf("%d\n", query(t1, t2 + 1));
      else
        printf("%d\n", min(query(t1, n), query(0, t2 + 1)));
    } else {
      int t3;
      scanf("%d", &t3);
      if (t1 <= t2)
        inc(t1, t2 + 1, t3);
      else {
        inc(t1, n, t3);
        inc(0, t2 + 1, t3);
      }
    }
  }
  return 0;
}
