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 double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) { return n | (1LL << i); }
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
const int MAX = 2e5 + 123;
int n;
long long a[MAX];
long long seg[MAX * 3], lazy[MAX * 3];
void init(int cur, int b, int e) {
  if (b == e) {
    seg[cur] = a[b];
    return;
  }
  int mid = (b + e) >> 1;
  init(cur * 2 + 1, b, mid);
  init(cur * 2 + 2, mid + 1, e);
  seg[cur] = min(seg[cur * 2 + 1], seg[cur * 2 + 2]);
}
void shift(int cur, int b, int e) {
  seg[cur] += lazy[cur];
  if (b != e) {
    lazy[cur * 2 + 1] += lazy[cur];
    lazy[cur * 2 + 2] += lazy[cur];
  }
  lazy[cur] = 0;
}
void upd(int cur, int b, int e, int l, int r, long long v) {
  if (lazy[cur]) shift(cur, b, e);
  if (l > e || r < b) return;
  if (l <= b && e <= r) {
    lazy[cur] += v;
    shift(cur, b, e);
    return;
  }
  int mid = (b + e) >> 1;
  upd(cur * 2 + 1, b, mid, l, r, v);
  upd(cur * 2 + 2, mid + 1, e, l, r, v);
  seg[cur] = min(seg[cur * 2 + 1], seg[cur * 2 + 2]);
}
long long ask(int cur, int b, int e, int l, int r) {
  if (lazy[cur]) shift(cur, b, e);
  if (l > e || r < b) return infLL;
  if (l <= b && e <= r) return seg[cur];
  int mid = (b + e) >> 1;
  long long ret1 = ask(cur * 2 + 1, b, mid, l, r);
  long long ret2 = ask(cur * 2 + 2, mid + 1, e, l, r);
  return min(ret1, ret2);
}
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();
  init(0, 0, n - 1);
  while (m--) {
    string s;
    getline(cin, s);
    stringstream st(s);
    int l = -1, r = -1;
    long long v = inf;
    int parser;
    while (st >> parser) {
      if (l == -1)
        l = parser;
      else if (r == -1)
        r = parser;
      else
        v = parser;
    }
    if (v == inf) {
      if (l <= r)
        cout << ask(0, 0, n - 1, l, r) << endl;
      else
        cout << min(ask(0, 0, n - 1, 0, r), ask(0, 0, n - 1, l, n - 1)) << endl;
    } else {
      if (l <= r)
        upd(0, 0, n - 1, l, r, v);
      else {
        upd(0, 0, n - 1, 0, r, v);
        upd(0, 0, n - 1, l, n - 1, v);
      }
    }
  }
  return 0;
}
