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 maxn = 2e5 + 100, maxlog = 22;
long long VAL[(1 << maxlog)], dif[(1 << maxlog)], tav[50], inf = 1e15;
int n, q;
void tavi() {
  for (int i = 0; i < 25; i++) tav[i] = 1 << i;
}
int L(int id) { return 2 * id + 1; }
int R(int id) { return 2 * id + 2; }
void up(int id) {
  VAL[L(id)] += dif[id];
  VAL[R(id)] += dif[id];
  dif[L(id)] += dif[id];
  dif[R(id)] += dif[id];
  dif[id] = 0;
}
void add_up(int a, int b, int val, int fi, int se, int idx) {
  if (a == fi and b == se) {
    VAL[idx] += val;
    dif[idx] += val;
    return;
  }
  up(idx);
  int mid = (fi + se) / 2;
  if (a < mid) add_up(a, min(b, mid), val, fi, mid, L(idx));
  if (b > mid) add_up(max(a, mid), b, val, mid, se, R(idx));
  VAL[idx] = min(VAL[L(idx)], VAL[R(idx)]);
  return;
}
long long get_min(int a, int b, int fi, int se, int idx) {
  if (a == fi and b == se) return VAL[idx];
  up(idx);
  int mid = (fi + se) / 2;
  long long ret = inf;
  if (a < mid) ret = min(ret, get_min(a, min(b, mid), fi, mid, L(idx)));
  if (b > mid) ret = min(ret, get_min(max(a, mid), b, mid, se, R(idx)));
  VAL[idx] = min(VAL[L(idx)], VAL[R(idx)]);
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    add_up(i, i + 1, a, 0, n, 0);
  }
  cin >> q;
  string chert;
  getline(cin, chert);
  while (q--) {
    string str;
    getline(cin, str);
    istringstream iss(str);
    int t = 0;
    for (int i = 0; i < (int)str.size(); i++)
      if (str[i] == ' ') t++;
    if (t == 1) {
      int x, y;
      iss >> x >> y;
      if (x <= y)
        cout << get_min(x, y + 1, 0, n, 0) << endl;
      else
        cout << min(get_min(x, n, 0, n, 0), get_min(0, y + 1, 0, n, 0)) << endl;
    } else {
      int x, y, z;
      iss >> x >> y >> z;
      if (x <= y)
        add_up(x, y + 1, z, 0, n, 0);
      else {
        add_up(x, n, z, 0, n, 0);
        add_up(0, y + 1, z, 0, n, 0);
      }
    }
  }
  return 0;
}
