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 arr[200005];
int N;
struct info {
  long long lazy, val;
  info() {
    lazy = 0LL;
    val = LLONG_MAX;
  }
  void show() { cout << val << " " << lazy << endl; }
} tree[3 * 200005];
void propagate(int node, int l, int r) {
  tree[node].val += tree[node].lazy;
  if (l != r) {
    tree[2 * node].lazy += tree[node].lazy;
    tree[2 * node + 1].lazy += tree[node].lazy;
  }
  tree[node].lazy = 0;
}
long long merge(long long x, long long y) { return min(x, y); }
void build(int node, int l, int r) {
  if (l == r) {
    tree[node].lazy = 0LL;
    tree[node].val = arr[l];
    return;
  }
  int mid = (l + r) / 2;
  build(node * 2, l, mid);
  build(node * 2 + 1, mid + 1, r);
  tree[node].lazy = 0LL;
  tree[node].val = merge(tree[node * 2].val, tree[2 * node + 1].val);
}
long long query(int node, int l, int r, int i, int j) {
  propagate(node, l, r);
  if (i > r || j < l) return LLONG_MAX;
  if (l >= i && r <= j) return tree[node].val;
  int mid = (l + r) / 2;
  long long x = query(node * 2, l, mid, i, j);
  long long y = query(node * 2 + 1, mid + 1, r, i, j);
  return merge(x, y);
}
void update(int node, int l, int r, int i, int j, long long val) {
  propagate(node, l, r);
  if (i > r || j < l) return;
  if (l >= i && r <= j) {
    tree[node].lazy += val;
    propagate(node, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(node * 2, l, mid, i, j, val);
  update(node * 2 + 1, mid + 1, r, i, j, val);
  tree[node].val = merge(tree[node * 2].val, tree[node * 2 + 1].val);
}
void print(int node, int l, int r) {
  cout << "[" << l << "," << r << "]:--> ";
  tree[node].show();
  if (l == r) return;
  int mid = (l + r) / 2;
  print(node * 2, l, mid);
  print(node * 2 + 1, mid + 1, r);
}
void print() { print(1, 0, N - 1); }
void build(int n) {
  N = n;
  build(1, 0, N - 1);
}
void update(int i, int j, long long val) {
  if (i <= j)
    update(1, 0, N - 1, i, j, val);
  else {
    update(1, 0, N - 1, i, N - 1, val);
    update(1, 0, N - 1, 0, j, val);
  }
}
long long query(int x, int y) {
  long long ans = LLONG_MAX;
  if (x <= y)
    ans = query(1, 0, N - 1, x, y);
  else {
    ans = query(1, 0, N - 1, x, N - 1);
    ans = min(ans, query(1, 0, N - 1, 0, y));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, q, x, y, z, k;
  string s;
  vector<long long> v;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  build(n);
  cin >> q;
  cin.ignore();
  while (q--) {
    v.clear();
    getline(cin, s);
    stringstream ss(s);
    while (ss >> x) v.push_back(x);
    if ((int)v.size() == 2) {
      cout << query(v[0], v[1]) << endl;
    } else {
      update(v[0], v[1], v[2]);
    }
  }
  return 0;
}
