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 seg[4 * N], lazy[4 * N], INF = 1e18;
int a[N];
int n;
void build(int id = 1, int s = 0, int e = n - 1) {
  if (s == e) {
    seg[id] = a[s];
    return;
  }
  int mid = s + (e - s) / 2;
  build(id * 2, s, mid);
  build(id * 2 + 1, mid + 1, e);
  seg[id] = min(seg[id * 2], seg[id * 2 + 1]);
}
long long query(int sq, int eq, int id = 1, int s = 0, int e = n - 1) {
  if (s > eq || e < sq) return INF;
  if (s >= sq && e <= eq) return seg[id] + lazy[id];
  int mid = s + (e - s) / 2;
  return min(query(sq, eq, id * 2, s, mid),
             query(sq, eq, id * 2 + 1, mid + 1, e)) +
         lazy[id];
}
void update(int su, int eu, int val, int id = 1, int s = 0, int e = n - 1) {
  if (s > eu || e < su) return;
  if (s >= su && e <= eu) {
    lazy[id] += val;
    return;
  }
  int mid = s + (e - s) / 2;
  update(su, eu, val, id * 2, s, mid);
  update(su, eu, val, id * 2 + 1, mid + 1, e);
  seg[id] = min(seg[id * 2] + lazy[id * 2], seg[id * 2 + 1] + lazy[id * 2 + 1]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int m;
  cin >> m;
  cin.ignore();
  build();
  while (m--) {
    string s;
    getline(cin, s);
    int l = 0, r = 0, v = 0, cnt = 0, f = 1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == ' ')
        cnt++;
      else if (cnt == 0)
        l = l * 10 + s[i] - '0';
      else if (cnt == 1)
        r = r * 10 + s[i] - '0';
      else if (cnt == 2) {
        if (s[i] == '-')
          f = -1;
        else
          v = v * 10 + s[i] - '0';
      }
    }
    v *= f;
    if (cnt == 1) {
      if (l <= r)
        cout << query(l, r) << endl;
      else
        cout << min(query(l, n - 1), query(0, r)) << endl;
    } else {
      if (l <= r)
        update(l, r, v);
      else {
        update(l, n - 1, v);
        update(0, r, v);
      }
    }
  }
  return 0;
}
