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 INF = 0x3f3f3f3f;
int min1[1000000], lazy[1000000];
void PushUp(int rt) { min1[rt] = min(min1[rt << 1], min1[rt << 1 | 1]); }
void PushDown(int rt) {
  if (lazy[rt]) {
    min1[rt << 1 | 1] += lazy[rt];
    min1[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt << 1] += lazy[rt];
    lazy[rt] = 0;
  }
}
void build(int l, int r, int rt) {
  if (l == r) {
    scanf("%d", &min1[rt]);
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, rt << 1);
  build(mid + 1, r, rt << 1 | 1);
  PushUp(rt);
}
void update(int ll, int rr, int x, int l, int r, int rt) {
  if (ll <= l && rr >= r) {
    lazy[rt] += x;
    min1[rt] += x;
    return;
  }
  PushDown(rt);
  int mid = l + r >> 1;
  if (ll <= mid) update(ll, rr, x, l, mid, rt << 1);
  if (rr > mid) update(ll, rr, x, mid + 1, r, rt << 1 | 1);
  PushUp(rt);
}
int query(int ll, int rr, int l, int r, int rt) {
  if (ll <= l && rr >= r) {
    return min1[rt];
  }
  PushDown(rt);
  int ans = INF, mid = l + r >> 1;
  if (ll <= mid) ans = min(ans, query(ll, rr, l, mid, rt << 1));
  if (rr > mid) ans = min(ans, query(ll, rr, mid + 1, r, rt << 1 | 1));
  return ans;
}
int main() {
  int n, l, r, x, q, i;
  scanf("%d", &n);
  build(0, n - 1, 1);
  scanf("%d", &q);
  memset(lazy, 0, sizeof(lazy));
  while (q--) {
    scanf("%d%d", &l, &r);
    if (getchar() == ' ') {
      scanf("%d", &x);
      if (l > r) {
        update(l, n - 1, x, 0, n - 1, 1);
        update(0, r, x, 0, n - 1, 1);
      } else {
        update(l, r, x, 0, n - 1, 1);
      }
    } else {
      if (l > r) {
        int ans = min(query(l, n - 1, 0, n - 1, 1), query(0, r, 0, n - 1, 1));
        printf("%d\n", ans);
      } else {
        int ans = query(l, r, 0, n - 1, 1);
        printf("%d\n", ans);
      }
    }
  }
  return 0;
}
