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 = 200005;
int n, m, l, r, val, a[MAXN];
bool opt;
namespace Segtree {
const long long Seg_INF = 1e18;
const int Seg_MAXN = 1000005;
struct SMT {
  long long Min, tag;
} tree[Seg_MAXN];
inline void build(int rt, int l, int r) {
  if (l == r) {
    tree[rt].Min = a[l];
    return;
  }
  int mid = l + r >> 1;
  build(rt << 1, l, mid);
  build(rt << 1 | 1, mid + 1, r);
  tree[rt].Min = min(tree[rt << 1].Min, tree[rt << 1 | 1].Min);
}
inline void update(int rt, int l, int r, int ansl, int ansr, int val) {
  if (ansl <= l && r <= ansr) {
    tree[rt].tag += val;
    return;
  }
  int mid = l + r >> 1;
  if (ansl <= mid) update(rt << 1, l, mid, ansl, ansr, val);
  if (mid < ansr) update(rt << 1 | 1, mid + 1, r, ansl, ansr, val);
  tree[rt].Min = min(tree[rt << 1].Min + tree[rt << 1].tag,
                     tree[rt << 1 | 1].Min + tree[rt << 1 | 1].tag);
}
inline long long query(int rt, int l, int r, int ansl, int ansr) {
  if (ansl <= l && r <= ansr) return tree[rt].Min + tree[rt].tag;
  int mid = l + r >> 1;
  long long ret = Seg_INF;
  if (ansl <= mid) ret = min(ret, query(rt << 1, l, mid, ansl, ansr));
  if (mid < ansr) ret = min(ret, query(rt << 1 | 1, mid + 1, r, ansl, ansr));
  return ret + tree[rt].tag;
}
}  // namespace Segtree
using namespace Segtree;
inline int read() {
  opt = 0;
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  if (ch == ' ') opt = 1;
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  build(1, 1, n);
  m = read();
  for (int i = 1; i <= m; i++) {
    l = read();
    r = read();
    l++;
    r++;
    if (!opt) {
      if (l <= r)
        printf("%lld\n", query(1, 1, n, l, r));
      else
        printf("%lld\n", min(query(1, 1, n, l, n), query(1, 1, n, 1, r)));
    } else {
      val = read();
      if (l <= r)
        update(1, 1, n, l, r, val);
      else {
        update(1, 1, n, l, n, val);
        update(1, 1, n, 1, r, val);
      }
    }
  }
  return 0;
}
