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-10;
const int inf = 2000000000;
int MOD1 = 1000000007;
int MOD2 = 1000000009;
inline bool checkBit(long long int n, long long int i) {
  return n & (1LL << i);
}
inline long long int setBit(long long int n, long long int i) {
  return n | (1LL << i);
  ;
}
inline long long int resetBit(long long int n, long long 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 bool isLeapYear(long long int year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long int &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long int modMul(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long int modAdd(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long int modSub(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long int modPow(long long int b, long long int p) {
  long long int r = 1LL;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1LL;
  }
  return r;
}
inline long long int modDiv(long long int a, long long int b) {
  return modMul(a, modPow(b, 1000000007 - 2));
}
bool comp(const pair<int, int> &p1, const pair<int, int> &p2) {
  return p1.second < p2.second;
}
long long int converter(string a) {
  long long int i, mul = 1, r, t, ans = 0LL;
  if (a.length() == 0) return 0;
  for (i = a.length() - 1; i >= 0; i--) {
    t = a[i] - '0';
    r = t % 10;
    ans += (mul * r);
    mul = mul * 10;
  }
  return ans;
}
long long int lazy[6 * 200005 + 15];
long long int tree[6 * 200005 + 15];
long long int a[200005 + 15];
void build(long long int node, long long int l, long long int r) {
  if (l == r) {
    tree[node] = a[l];
    return;
  }
  long long int mid = (l + r) >> 1;
  build(node * 2, l, mid);
  build(node * 2 + 1, mid + 1, r);
  tree[node] = min(tree[node * 2], tree[node * 2 + 1]);
}
void update(long long int node, long long int l, long long int r,
            long long int b, long long int e, long long int val) {
  tree[node] += lazy[node];
  if (lazy[node] != 0) {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
  }
  lazy[node] = 0;
  if (r < b || l > e) return;
  if (b <= l && e >= r) {
    lazy[node] += val;
    return;
  }
  long long int mid = (l + r) >> 1;
  update(node * 2, l, mid, b, e, val);
  update(node * 2 + 1, mid + 1, r, b, e, val);
  tree[node] = min(tree[node * 2] + lazy[node * 2],
                   tree[node * 2 + 1] + lazy[node * 2 + 1]);
}
long long int query(long long int node, long long int l, long long int r,
                    long long int b, long long int e) {
  tree[node] += lazy[node];
  if (lazy[node] != 0) {
    lazy[node * 2] += lazy[node];
    lazy[node * 2 + 1] += lazy[node];
  }
  lazy[node] = 0;
  if (r < b || l > e) return (long long int)2e18;
  if (b <= l && e >= r) {
    return tree[node] + lazy[node];
  }
  long long int mid = (l + r) >> 1;
  long long int ret1 = query(node * 2, l, mid, b, e);
  long long int ret2 = query(node * 2 + 1, mid + 1, r, b, e);
  tree[node] = min(tree[node * 2] + lazy[node * 2],
                   tree[node * 2 + 1] + lazy[node * 2 + 1]);
  return min(ret1, ret2);
}
int main() {
  long long int n, i;
  scanf("%lld", &n);
  for (i = 1; i <= 3 * 100005; i++) {
    tree[i] = (long long int)2e18;
    lazy[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  build(1, 1, n);
  long long int m;
  cin >> m;
  getchar();
  for (i = 1; i <= m; i++) {
    long long int c, l, r, val, f = 1, j = 0;
    char s[50];
    gets(s);
    j = 0;
    string L = "", R = "", VAL = "";
    while (s[j] != ' ') {
      L += s[j];
      j++;
    }
    j++;
    while (s[j] != ' ' && j < strlen(s)) {
      R += s[j];
      j++;
    }
    j++;
    if (s[j] == '-' && j < strlen(s)) {
      f = -1;
      j++;
    }
    while (j < strlen(s)) {
      VAL += s[j];
      j++;
    }
    l = converter(L);
    r = converter(R);
    l++;
    r++;
    if (VAL.size() > 0) {
      val = (long long int)f * (long long int)converter(VAL);
      if (r < l) {
        update(1, 1, n, l, n, val);
        update(1, 1, n, 1, r, val);
      } else
        update(1, 1, n, l, r, val);
    } else {
      if (r < l) {
        cout << min(query(1, 1, n, l, n), query(1, 1, n, 1, r)) << '\n';
      } else
        cout << query(1, 1, n, l, r) << '\n';
    }
  }
  return 0;
}
