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 = 200009;
const long long MAXN = 0x7f7f7f7f7f7f7f7f;
int n, m;
long long tree[N * 4], tag[N * 4];
long long v[N];
void build(int k, int l, int r) {
  if (l == r) {
    tree[k] = v[l];
    return;
  }
  int mid = (l + r) / 2;
  build(k * 2, l, mid);
  build(k * 2 + 1, mid + 1, r);
  tree[k] = min(tree[k * 2], tree[k * 2 + 1]);
}
void modify(int k, int l, int r, int x, int y, int val) {
  if (l >= x && r <= y) {
    tag[k] += val;
    return;
  }
  int mid = (l + r) / 2;
  if (mid >= x) modify(k * 2, l, mid, x, y, val);
  if (mid < y) modify(k * 2 + 1, mid + 1, r, x, y, val);
  tree[k] = min(tree[k * 2] + tag[k * 2], tree[k * 2 + 1] + tag[k * 2 + 1]);
}
long long query(int k, int l, int r, int x, int y) {
  if (l >= x && r <= y) {
    return tree[k] + tag[k];
  }
  int mid = (l + r) / 2;
  long long left = MAXN, right = MAXN;
  if (mid >= x) left = query(k * 2, l, mid, x, y);
  if (mid < y) right = query(k * 2 + 1, mid + 1, r, x, y);
  return min(left, right) + tag[k];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &v[i]);
  }
  build(1, 1, n);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long val;
    scanf("%d%d", &x, &y);
    x++, y++;
    char op;
    op = getchar();
    if (op == '\n') {
      if (x <= y) {
        printf("%lld\n", query(1, 1, n, x, y));
      } else {
        long long ans;
        ans = query(1, 1, n, 1, y);
        ans = min(ans, query(1, 1, n, x, n));
        printf("%lld\n", ans);
      }
    } else {
      scanf("%lld", &val);
      if (x <= y) {
        modify(1, 1, n, x, y, val);
      } else {
        modify(1, 1, n, x, n, val);
        modify(1, 1, n, 1, y, val);
      }
    }
  }
  return 0;
}
