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 int V[200010];
long long int AI[4 * 200010];
long long int laz[4 * 200010];
long long int n, m;
inline long long int minim(long long int x, long long int y) {
  if (x < y) return x;
  return y;
}
void build(long long int node, long long int st, long long int dr);
void lazy(long long int node, long long int st, long long int dr,
          long long int x, long long int y, long long int val);
long long int query(long long int node, long long int st, long long int dr,
                    long long int x, long long int y);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int i, x, y, var1, var2, val;
  char c;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> V[i];
  build(1, 1, n);
  cin >> m;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    x++;
    y++;
    cin.get(c);
    if (c == ' ') {
      cin >> val;
      if (x <= y)
        lazy(1, 1, n, x, y, val);
      else {
        lazy(1, 1, n, 1, y, val);
        lazy(1, 1, n, x, n, val);
      }
    } else if (x <= y)
      cout << query(1, 1, n, x, y) << '\n';
    else {
      var1 = query(1, 1, n, 1, y);
      var2 = query(1, 1, n, x, n);
      cout << minim(var1, var2) << '\n';
    }
  }
  return 0;
}
void build(long long int node, long long int st, long long int dr) {
  if (st == dr) {
    AI[node] = V[st];
    return;
  }
  long long int mij = (st + dr) / 2;
  build(2 * node, st, mij);
  build(2 * node + 1, mij + 1, dr);
  AI[node] = minim(AI[2 * node], AI[2 * node + 1]);
}
void lazy(long long int node, long long int st, long long int dr,
          long long int x, long long int y, long long int val) {
  if (laz[node] && st != dr) {
    long long int mij = (st + dr) / 2;
    laz[2 * node] += laz[node];
    AI[2 * node] += laz[node];
    laz[2 * node + 1] += laz[node];
    AI[2 * node + 1] += laz[node];
    laz[node] = 0;
  }
  if (st >= x && dr <= y) {
    laz[node] += val;
    AI[node] += val;
    return;
  }
  long long int mij = (st + dr) / 2;
  if (x <= mij) lazy(2 * node, st, mij, x, y, val);
  if (y > mij) lazy(2 * node + 1, mij + 1, dr, x, y, val);
  AI[node] = minim(AI[2 * node], AI[2 * node + 1]);
}
long long int query(long long int node, long long int st, long long int dr,
                    long long int x, long long int y) {
  long long int mij = (st + dr) / 2, var1 = INT_MAX / 2, var2 = INT_MAX / 2;
  if (laz[node] && st != dr) {
    laz[2 * node] += laz[node];
    AI[2 * node] += laz[node];
    laz[2 * node + 1] += laz[node];
    AI[2 * node + 1] += laz[node];
    laz[node] = 0;
  }
  if (st >= x && dr <= y) return AI[node];
  if (x <= mij) var1 = query(2 * node, st, mij, x, y);
  if (y > mij) var2 = query(2 * node + 1, mij + 1, dr, x, y);
  return minim(var1, var2);
}
