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;
long long t[1000005 << 2], a[1000005], tag[1000005];
inline int ls(int x) { return x << 1; }
inline int rs(int x) { return x << 1 | 1; }
inline long long min(long long a, long long b) { return (a < b) ? a : b; }
inline void pushUp(int p) {
  t[p] = min(t[ls(p)] + tag[ls(p)], t[rs(p)] + tag[rs(p)]);
}
inline void build(int p, int l, int r) {
  if (l == r) {
    t[p] = a[l];
  } else {
    int mid = (l + r) >> 1;
    build(ls(p), l, mid);
    build(rs(p), mid + 1, r);
    pushUp(p);
  }
}
inline void update(int nl, int nr, int l, int r, int p, int k) {
  if (nl <= l && r <= nr) {
    tag[p] += k;
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= nl) update(nl, nr, l, mid, ls(p), k);
  if (mid < nr) update(nl, nr, mid + 1, r, rs(p), k);
  pushUp(p);
}
inline long long query(int nl, int nr, int l, int r, int p) {
  if (nl <= l && r <= nr) return t[p] + tag[p];
  long long mid = (l + r) >> 1, res = 0x7fffffffffffffff;
  if (mid >= nl) res = min(res, query(nl, nr, l, mid, ls(p)));
  if (mid < nr) res = min(res, query(nl, nr, mid + 1, r, rs(p)));
  return res + tag[p];
}
int space = 0;
template <class T>
inline T read() {
  space = 0;
  register int s = 0, w = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
  if (c == ' ') space = 1;
  return s * w;
}
int main(int argc, char** args) {
  int n = 0, m = 0;
  n = read<int>();
  for (int i = 1; i <= n; i++) {
    a[i] = read<long long>();
  }
  m = read<int>();
  build(1, 1, n);
  for (int i = 0; i < m; i++) {
    int l = 0, r = 0;
    long long k = 0;
    l = read<int>(), r = read<int>();
    l++, r++;
    int temp = space;
    if (space) k = read<long long>();
    if (!temp) {
      if (l > r) {
        cout << min(query(l, n, 1, n, 1), query(1, r, 1, n, 1)) << endl;
      } else
        cout << query(l, r, 1, n, 1) << endl;
    } else {
      if (l > r) {
        update(l, n, 1, n, 1, k);
        update(1, r, 1, n, 1, k);
      } else
        update(l, r, 1, n, 1, k);
    }
  }
}
