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 L, R, v, d[5000005], val[5000005], ans;
void xe(long long a, long long l, long long r) {
  if (l >= L && r <= R) {
    ans = min(d[a], ans);
    return;
  }
  if (r < L || R < l) {
    return;
  }
  val[2 * a] += val[a];
  val[2 * a + 1] += val[a];
  long long mid = (l + r) / 2;
  d[2 * a] += val[a];
  d[2 * a + 1] += val[a];
  val[a] = 0;
  xe(2 * a, l, mid);
  xe(2 * a + 1, mid + 1, r);
}
void upd(long long a, long long l, long long r) {
  if (l >= L && r <= R) {
    val[a] += v;
    d[a] += v;
    return;
  }
  if (r < L || R < l) {
    return;
  }
  val[2 * a] += val[a];
  val[2 * a + 1] += val[a];
  long long mid = (l + r) / 2;
  d[2 * a] += val[a];
  d[2 * a + 1] += val[a];
  val[a] = 0;
  upd(2 * a, l, mid);
  upd(2 * a + 1, mid + 1, r);
  d[a] = min(d[2 * a], d[2 * a + 1]);
}
long long n, c, t, a, l, r;
char ch;
int main() {
  cin >> n;
  c = 1;
  while (c < n) {
    c *= 2;
  }
  for (int i = 0; i < n; i++) {
    cin >> d[i + c];
  }
  for (int i = c - 1; i >= 1; i--) {
    if (2 * i > c + n - 1) {
      continue;
    } else if (2 * i + 1 > c + n - 1) {
      d[i] = d[i * 2];
    } else
      d[i] = min(d[i * 2], d[i * 2 + 1]);
  }
  cin >> t;
  while (t--) {
    cin >> l >> r;
    l++;
    r++;
    L = l;
    R = r;
    ch = getchar();
    if (ch == ' ') {
      cin >> v;
      if (l > r) {
        L = l;
        R = n;
        upd(1, 1, c);
        L = 1;
        R = r;
        upd(1, 1, c);
      } else
        upd(1, 1, c);
    } else {
      ans = 1e18;
      if (l > r) {
        L = l;
        R = n;
        xe(1, 1, c);
        L = 1;
        R = r;
        xe(1, 1, c);
      } else
        xe(1, 1, c);
      cout << ans << endl;
    }
  }
}
