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 N = 200005;
int a[N], m[4 * N], lz[4 * N] = {0};
void build(int i, int s, int e) {
  if (s > e) return;
  if (s == e) {
    m[i] = a[s];
    return;
  }
  int q = (s + e) >> 1;
  build(2 * i + 1, s, q);
  build(2 * i + 2, q + 1, e);
  m[i] = min(m[2 * i + 1], m[2 * i + 2]);
}
void push(int i, int s, int e) {
  if (lz[i]) {
    m[i] += lz[i];
    if (s != e) {
      lz[2 * i + 1] += lz[i];
      lz[2 * i + 2] += lz[i];
    }
    lz[i] = 0;
  }
}
void update(int i, int s, int e, int l, int r, int v) {
  push(i, s, e);
  if (s > e || s > r || e < l) return;
  if (s >= l && e <= r) {
    m[i] += v;
    if (s != e) {
      lz[2 * i + 1] += v;
      lz[2 * i + 2] += v;
    }
    return;
  }
  int q = (s + e) / 2;
  update(2 * i + 1, s, q, l, r, v);
  update(2 * i + 2, q + 1, e, l, r, v);
  m[i] = min(m[2 * i + 1], m[2 * i + 2]);
}
int get(int i, int s, int e, int l, int r) {
  if (s > e || s > r || e < l) return INT_MAX;
  push(i, s, e);
  if (s >= l && e <= r) return m[i];
  int q = (s + e) / 2;
  return min(get(2 * i + 1, s, q, l, r), get(2 * i + 2, q + 1, e, l, r));
}
void printM(int n) {
  for (int i = 0; i < 2 * n; i++) printf("%d %d\n", i, m[i]);
  printf("\n");
}
int main() {
  int n, Q, l, r, v;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  build(0, 0, n - 1);
  char ch;
  scanf("%d", &Q);
  while (Q--) {
    scanf("%d %d%c", &l, &r, &ch);
    if (ch != '\n') {
      scanf("%d", &v);
      if (r >= l)
        update(0, 0, n - 1, l, r, v);
      else {
        update(0, 0, n - 1, 0, r, v);
        update(0, 0, n - 1, l, n - 1, v);
      }
    } else {
      if (r >= l)
        printf("%d\n", get(0, 0, n - 1, l, r));
      else
        printf("%d\n", min(get(0, 0, n - 1, 0, r), get(0, 0, n - 1, l, n - 1)));
    }
  }
  return 0;
}
