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;
struct vertex {
  long long his, min;
};
vertex tree[200000 * 4 + 4];
inline long long min(const long long a, const long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long up;
void update(int v, int l, int r, int kl, int kr) {
  if (l == kl && r == kr) {
    tree[v].his += up;
    tree[v].min += up;
  } else {
    int mid = (l + r) / 2;
    if (kl > mid) update(v * 2 + 1, mid + 1, r, kl, kr);
    if (kr <= mid) update(v * 2, l, mid, kl, kr);
    if (kl <= mid && kr > mid) {
      update(v * 2, l, mid, kl, mid);
      update(v * 2 + 1, mid + 1, r, mid + 1, kr);
    }
    tree[v].min = min(tree[v * 2].min, tree[v * 2 + 1].min) + tree[v].his;
  }
}
long long get(int v, int l, int r, int kl, int kr) {
  if (l == kl && r == kr) {
    return tree[v].min;
  } else {
    int mid = (l + r) / 2;
    if (kl > mid) return get(v * 2 + 1, mid + 1, r, kl, kr) + tree[v].his;
    if (kr <= mid) return get(v * 2, l, mid, kl, kr) + tree[v].his;
    if (kl <= mid && kr > mid)
      return min(get(v * 2, l, mid, kl, mid),
                 get(v * 2 + 1, mid + 1, r, mid + 1, kr)) +
             tree[v].his;
  }
}
int n, m;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> up;
    update(1, 0, n - 1, i, i);
  }
  scanf("%d", &m);
  char ch;
  int l, r;
  for (; m > 0; m--) {
    scanf("%d %d%c", &l, &r, &ch);
    if (ch == ' ') {
      cin >> up;
      if (l <= r)
        update(1, 0, n - 1, l, r);
      else {
        update(1, 0, n - 1, l, n - 1);
        update(1, 0, n - 1, 0, r);
      }
    } else {
      if (l <= r)
        cout << get(1, 0, n - 1, l, r) << endl;
      else
        cout << min(get(1, 0, n - 1, l, n - 1), get(1, 0, n - 1, 0, r)) << endl;
    }
  }
  return 0;
}
