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 N = 2e5 + 5;
long long tree[4 * N], add[4 * N], v[N];
void build(int node, int l, int r) {
  if (l == r)
    tree[node] = v[l];
  else {
    int m = (l + r) / 2;
    build(2 * node, l, m);
    build(2 * node + 1, m + 1, r);
    tree[node] = min(tree[2 * node], tree[2 * node + 1]);
  }
}
void push(int node, int l, int r) {
  if (l < r && add[node]) {
    tree[2 * node] += add[node];
    add[2 * node] += add[node];
    tree[2 * node + 1] += add[node];
    add[2 * node + 1] += add[node];
    add[node] = 0;
  }
}
void update(int node, int l, int r, int x, int y, long long val) {
  push(node, l, r);
  if (y < l || x > r) return;
  if (x <= l && r <= y) {
    add[node] += val;
    tree[node] += val;
    return;
  }
  push(node, l, r);
  int m = (l + r) / 2;
  update(2 * node, l, m, x, y, val);
  update(2 * node + 1, m + 1, r, x, y, val);
  tree[node] = min(tree[2 * node], tree[2 * node + 1]);
}
long long query(int node, int l, int r, int x, int y) {
  push(node, l, r);
  if (x <= l && r <= y) return tree[node];
  long long ans = LLONG_MAX;
  int m = (l + r) / 2;
  if (x <= m) ans = min(ans, query(2 * node, l, m, x, y));
  if (y > m) ans = min(ans, query(2 * node + 1, m + 1, r, x, y));
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> v[i];
  build(1, 1, n);
  int m;
  cin >> m;
  cin.ignore();
  for (int i = 1; i <= m; i++) {
    string s;
    getline(cin, s);
    int a, b, c;
    int z = sscanf(s.c_str(), "%d %d %d", &a, &b, &c);
    if (z == 3) {
      if (a > b) {
        update(1, 1, n, a + 1, n, c);
        update(1, 1, n, 1, b + 1, c);
      } else {
        update(1, 1, n, a + 1, b + 1, c);
      }
    } else {
      if (a > b)
        cout << min(query(1, 1, n, a + 1, n), query(1, 1, n, 1, b + 1)) << "\n";
      else
        cout << query(1, 1, n, a + 1, b + 1) << "\n";
    }
  }
}
