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 maxm = (int)1e7 + 100;
const int maxn = (int)2e5 + 100;
int n;
long long a[maxn];
long long u[4 * maxn];
long long t[4 * maxn];
void build(int v, int l, int r) {
  if (l == r) {
    t[v] = a[l];
  } else {
    int mid = (l + r) / 2;
    build(v * 2, l, mid);
    build(v * 2 + 1, mid + 1, r);
    t[v] = min(t[v * 2], t[v * 2 + 1]);
  }
}
void push(int v, int l, int r) {
  if (l == r) return;
  u[v * 2] += u[v];
  u[v * 2 + 1] += u[v];
  t[v * 2] += u[v];
  t[v * 2 + 1] += u[v];
  u[v] = 0;
}
void upd(int v, int tl, int tr, int l, int r, int z) {
  push(v, tl, tr);
  if (tl > r || l > tr) return;
  if (l <= tl && tr <= r) {
    t[v] += z;
    u[v] += z;
  } else {
    int mid = (tl + tr) / 2;
    upd(v * 2, tl, mid, l, r, z);
    upd(v * 2 + 1, mid + 1, tr, l, r, z);
    t[v] = min(t[v * 2], t[v * 2 + 1]);
  }
}
long long get(int v, int tl, int tr, int l, int r) {
  push(v, tl, tr);
  if (tl > r || l > tr) return (long long)(1e18);
  if (l <= tl && tr <= r) {
    return t[v];
  } else {
    int mid = (tl + tr) / 2;
    return min(get(v * 2, tl, mid, l, r), get(v * 2 + 1, mid + 1, tr, l, r));
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  build(1, 0, n - 1);
  int q;
  cin >> q;
  cin.ignore();
  for (int i = 0; i < q; i++) {
    string s;
    getline(cin, s);
    stringstream ss(s);
    int x, y, z;
    ss >> x >> y;
    if (ss >> z) {
      if (x <= y) {
        upd(1, 0, n - 1, x, y, z);
      } else {
        upd(1, 0, n - 1, x, n - 1, z);
        upd(1, 0, n - 1, 0, y, z);
      }
    } else {
      if (x <= y) {
        cout << get(1, 0, n - 1, x, y) << "\n";
      } else {
        cout << min(get(1, 0, n - 1, x, n - 1), get(1, 0, n - 1, 0, y)) << "\n";
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
