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 double pi = acos(-1);
const int N = (int)1e6 + 7, mod = 1000000007, M = 2e9;
struct node {
  long long mn, lazy;
} s[1 << 19];
struct st {
  node emp = {1 << 60, 0ll};
  st(int n) { build(0, n - 1, 0); }
  node merg(node x, node y) {
    node res;
    res.lazy = 0;
    res.mn = min(x.mn, y.mn);
    return res;
  }
  void check(int i, bool cont) {
    if (s[i].lazy) {
      s[i].mn += s[i].lazy;
      if (cont) {
        int l = 2 * i + 1, r = l + 1;
        s[l].lazy += s[i].lazy;
        s[r].lazy += s[i].lazy;
      }
      s[i].lazy = 0;
    }
  }
  void build(int from, int to, int i) {
    if (from == to) {
      scanf("%I64d", &s[i].mn);
      s[i].lazy = 0;
      return;
    }
    int mid = (from + to) >> 1, l = 2 * i + 1, r = l + 1;
    build(from, mid, l);
    build(mid + 1, to, r);
    s[i] = merg(s[l], s[r]);
  }
  void update(int sq, int eq, int v, int from, int to, int i) {
    check(i, from != to);
    if (from > eq || to < sq) return;
    if (from >= sq && to <= eq) {
      s[i].mn += v;
      if (from != to) {
        int l = 2 * i + 1, r = l + 1;
        s[l].lazy += v;
        s[r].lazy += v;
      }
      return;
    }
    int mid = (from + to) >> 1, l = 2 * i + 1, r = l + 1;
    update(sq, eq, v, from, mid, l);
    update(sq, eq, v, mid + 1, to, r);
    s[i] = merg(s[l], s[r]);
  }
  node getMin(int sq, int eq, int from, int to, int i) {
    if (from > eq || to < sq) return emp;
    check(i, from != to);
    if (from >= sq && to <= eq) return s[i];
    int mid = (from + to) >> 1, l = 2 * i + 1, r = l + 1;
    if (eq <= mid) return getMin(sq, eq, from, mid, l);
    if (sq > mid) return getMin(sq, eq, mid + 1, to, r);
    return merg(getMin(sq, eq, from, mid, l), getMin(sq, eq, mid + 1, to, r));
  }
};
int n, q, x, y, v, t;
char buf[100];
long long ans;
void debug(st seg) {
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      cout << i << ' ' << j << ' ' << seg.getMin(i, j, 0, n - 1, 0).mn << endl;
    }
  }
}
int main() {
  scanf("%d", &n);
  st seg(n);
  scanf("%d", &q);
  gets(buf);
  while (q--) {
    gets(buf);
    string s = buf;
    istringstream second(s);
    vector<int> inp;
    int tmp;
    while (second >> tmp) inp.push_back(tmp);
    if (inp.size() == 2) {
      if (inp[0] > inp[1])
        ans = min(seg.getMin(0, inp[1], 0, n - 1, 0).mn,
                  seg.getMin(inp[0], n - 1, 0, n - 1, 0).mn);
      else
        ans = seg.getMin(inp[0], inp[1], 0, n - 1, 0).mn;
      printf("%I64d\n", ans);
    } else {
      if (inp[0] > inp[1]) {
        seg.update(inp[0], n - 1, inp[2], 0, n - 1, 0);
        seg.update(0, inp[1], inp[2], 0, n - 1, 0);
      } else
        seg.update(inp[0], inp[1], inp[2], 0, n - 1, 0);
    }
  }
  return 0;
}
