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 int MAXN = 2e5 + 5;
const int INF = 1e9;
long long seg[4 * MAXN];
long long lazy[4 * MAXN];
long long arr[MAXN];
void push(int pos) {
  seg[pos << 1] += lazy[pos];
  lazy[pos << 1] += lazy[pos];
  seg[(pos << 1) + 1] += lazy[pos];
  lazy[(pos << 1) + 1] += lazy[pos];
  lazy[pos] = 0;
}
void upd(int pos, int l, int r, int ql, int qr, long long add) {
  if (ql > qr) return;
  if (l == ql && r == qr) {
    seg[pos] += add;
    lazy[pos] += add;
  } else {
    push(pos);
    int m = (l + r) >> 1;
    upd(pos << 1, l, m, ql, min(qr, m), add);
    upd((pos << 1) + 1, m + 1, r, max(ql, m + 1), qr, add);
    seg[pos] = min(seg[pos << 1], seg[(pos << 1) + 1]);
  }
}
long long que(int pos, int l, int r, int ql, int qr) {
  if (ql > qr) return INF;
  if (ql <= l && r <= qr) return seg[pos];
  push(pos);
  int m = (l + r) >> 1;
  return min(que(pos << 1, l, m, ql, min(qr, m)),
             que((pos << 1) + 1, m + 1, r, max(ql, m + 1), qr));
}
int main() {
  int n;
  scanf("%d", &n);
  long long x;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &x);
    upd(1, 0, n - 1, i, i, x);
  }
  int m;
  scanf("%d", &m);
  while (m--) {
    int l, r;
    char c;
    scanf("%d %d%c", &l, &r, &c);
    if (c != '\n') {
      long long v;
      scanf("%I64d", &v);
      if (l <= r) {
        upd(1, 0, n - 1, l, r, v);
      } else {
        upd(1, 0, n - 1, 0, r, v);
        upd(1, 0, n - 1, l, n - 1, v);
      }
    } else {
      if (l <= r) {
        printf("%I64d\n", que(1, 0, n - 1, l, r));
      } else {
        long long y = min(que(1, 0, n - 1, 0, r), que(1, 0, n - 1, l, n - 1));
        printf("%I64d\n", y);
      }
    }
  }
}
