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 long long maxn = 2e5 + 5;
struct segement_tree {
  long long tr[maxn << 2], a[maxn], tag[maxn << 2];
  long long n, m, cnt, res, ans, now, pd = 0;
  inline long long read() {
    pd = 0;
    long long s = 0, ff = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
      if (ch == '-') ff = -1;
      ch = getchar();
    }
    while (isdigit(ch)) s = (s << 1) + (s << 3) + ch - 48, ch = getchar();
    if (ch == ' ') pd = 1;
    return s * ff;
  }
  inline void build(long long rt, long long l, long long r) {
    if (l == r) {
      tr[rt] = a[l];
      return;
    }
    long long mid = (l + r) / 2;
    build(rt << 1, l, mid);
    build(rt << 1 | 1, mid + 1, r);
    tr[rt] = min(tr[rt << 1], tr[rt << 1 | 1]);
  }
  inline void modify(long long rt, long long l, long long r, long long ll,
                     long long rr, long long val) {
    if (ll <= l && r <= rr) {
      tag[rt] += val;
      return;
    }
    long long mid = (l + r) / 2;
    if (ll <= mid) modify(rt << 1, l, mid, ll, rr, val);
    if (rr > mid) modify(rt << 1 | 1, mid + 1, r, ll, rr, val);
    tr[rt] =
        min(tr[rt << 1] + tag[rt << 1], tr[rt << 1 | 1] + tag[rt << 1 | 1]);
  }
  inline long long query(long long rt, long long l, long long r, long long ll,
                         long long rr) {
    if (ll <= l && r <= rr) return tr[rt] + tag[rt];
    long long mid = (l + r) / 2, res1 = 1e18, res2 = 1e18;
    if (ll <= mid) res1 = query(rt << 1, l, mid, ll, rr);
    if (rr > mid) res2 = query(rt << 1 | 1, mid + 1, r, ll, rr);
    return min(res1, res2) + tag[rt];
  }
  inline void solve() {
    n = read();
    for (register long long i = 1; i <= n; i++) a[i] = read();
    build(1, 1, n);
    m = read();
    while (m--) {
      long long lf = read(), rg = read();
      lf++, rg++;
      if (!pd) {
        if (lf > rg)
          printf("%lld\n", min(query(1, 1, n, lf, n), query(1, 1, n, 1, rg)));
        else
          printf("%lld\n", query(1, 1, n, lf, rg));
      } else {
        long long val = read();
        if (lf > rg)
          modify(1, 1, n, lf, n, val), modify(1, 1, n, 1, rg, val);
        else
          modify(1, 1, n, lf, rg, val);
      }
    }
  }
} ha_ha;
signed main() {
  ha_ha.solve();
  return 0;
}
