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>
const int maxN = 2e5 + 5;
template <class T>
inline void read(T &x) {
  x = 0;
  register T f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
struct SegT {
  int lc, rc;
  long long val, tag;
};
SegT tr[maxN << 1];
int node, root;
int n, m, a[maxN];
void build(int &p, int l, int r) {
  if (!p) p = ++node;
  if (l == r) {
    tr[p].val = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(tr[p].lc, l, mid), build(tr[p].rc, mid + 1, r);
  tr[p].val = std::min(tr[tr[p].lc].val, tr[tr[p].rc].val);
}
inline void maintain(int p, long long val) {
  tr[p].val += val;
  tr[p].tag += val;
}
inline void pushDown(int p) {
  if (!tr[p].lc) tr[p].lc = ++node;
  if (!tr[p].rc) tr[p].rc = ++node;
  maintain(tr[p].lc, tr[p].tag);
  maintain(tr[p].rc, tr[p].tag);
  tr[p].tag = 0;
}
void update(int p, int l, int r, int ql, int qr, long long val) {
  if (ql > r || qr < l) return;
  if (ql <= l && r <= qr) return maintain(p, val);
  if (tr[p].tag) pushDown(p);
  int mid = (l + r) >> 1;
  update(tr[p].lc, l, mid, ql, qr, val),
      update(tr[p].rc, mid + 1, r, ql, qr, val);
  tr[p].val = std::min(tr[tr[p].lc].val, tr[tr[p].rc].val);
}
long long query(int p, int l, int r, int ql, int qr) {
  if (ql > r || qr < l) return 1e18;
  if (ql <= l && r <= qr) return tr[p].val;
  if (tr[p].tag) pushDown(p);
  int mid = (l + r) >> 1;
  long long ret = 1e18;
  ret = std::min(ret, query(tr[p].lc, l, mid, ql, qr));
  ret = std::min(ret, query(tr[p].rc, mid + 1, r, ql, qr));
  return ret;
}
signed main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i]);
  build(root, 1, n);
  read(m);
  for (; m; --m) {
    int l, r, k;
    std::cin >> l >> r;
    ++l, ++r;
    char c = getchar();
    if (c == '\n') {
      if (l > r)
        printf("%lld\n", std::min(query(1, 1, n, 1, r), query(1, 1, n, l, n)));
      else
        printf("%lld\n", query(1, 1, n, l, r));
    } else {
      read(k);
      if (l > r)
        update(1, 1, n, l, n, k), update(1, 1, n, 1, r, k);
      else
        update(1, 1, n, l, r, k);
    }
  }
  return 0;
}
