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 = 2e5 + 10, Inf = 1e9 + 1;
long long arr[Maxn], seg[4 * Maxn], lazy[4 * Maxn], n, q;
char c;
void build(int s = 0, int e = n, int id = 0) {
  if (s + 1 == e) {
    seg[id] = arr[s];
    return;
  }
  int mid = s + e >> 1;
  build(s, mid, id * 2 + 1);
  build(mid, e, id * 2 + 2);
  seg[id] = min(seg[id * 2 + 1], seg[id * 2 + 2]);
}
void shift(int l, int r, int id) {
  lazy[id * 2 + 1] += lazy[id], seg[id * 2 + 1] += lazy[id];
  lazy[id * 2 + 2] += lazy[id], seg[id * 2 + 2] += lazy[id];
  lazy[id] = 0;
}
void inc(int x, int l, int r, int s = 0, int e = n, int id = 0) {
  if (r <= s || e <= l) return;
  if (l <= s && e <= r) {
    lazy[id] += x;
    seg[id] += x;
    return;
  }
  shift(s, e, id);
  int mid = s + e >> 1;
  inc(x, l, r, s, mid, id * 2 + 1);
  inc(x, l, r, mid, e, id * 2 + 2);
  seg[id] = min(seg[id * 2 + 1], seg[id * 2 + 2]);
}
long long get(int l, int r, int s = 0, int e = n, int id = 0) {
  if (r <= s || e <= l) return Inf;
  if (l <= s && e <= r) {
    return seg[id];
  }
  shift(s, e, id);
  int mid = s + e >> 1;
  return min(get(l, r, s, mid, id * 2 + 1), get(l, r, mid, e, id * 2 + 2));
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  build();
  cin >> q;
  for (int i = 0, a, b, d; i < q; i++) {
    scanf("%d %d%c", &a, &b, &c);
    b++;
    if (c == ' ') {
      cin >> d;
      if (b <= a)
        inc(d, a, n), inc(d, 0, b);
      else
        inc(d, a, b);
    } else {
      if (b <= a)
        cout << min(get(a, n), get(0, b)) << '\n';
      else
        cout << get(a, b) << '\n';
    }
  }
}
