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 INF = 1 << 28;
const long long LINF = 1ll << 61;
const int buk = 450;
int n, m, q;
long long a[200111], add[200111], b[200111];
void update(int id) {
  b[id] = LINF;
  for (int i = id * buk; i < id * buk + buk; i++) b[id] = min(b[id], a[i]);
}
long long query(int l, int r) {
  long long res = LINF;
  int i = l;
  while (i % buk != 0 && i <= r) res = min(res, a[i] + add[i / buk]), i++;
  while (i + buk - 1 <= r) res = min(res, b[i / buk] + add[i / buk]), i += buk;
  while (i <= r) res = min(res, a[i] + add[i / buk]), i++;
  return res;
}
void inc(int l, int r, int d) {
  int i = l;
  while (i % buk != 0 && i <= r) a[i] += d, i++;
  update(l / buk);
  while (i + buk - 1 <= r) add[i / buk] += d, i += buk;
  while (i <= r) a[i] += d, i++;
  update(r / buk);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i <= (n - 1) / buk; i++) update(i);
  cin >> q;
  int l, r, d;
  while (q--) {
    cin >> l >> r;
    if (cin.get() == 10) {
      if (l <= r)
        cout << query(l, r) << endl;
      else
        cout << min(query(0, r), query(l, n - 1)) << endl;
    } else {
      cin >> d;
      if (l <= r)
        inc(l, r, d);
      else
        inc(0, r, d), inc(l, n - 1, d);
    }
  }
  return 0;
}
