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;
long long segtree[4 * 200010];
int inp[200010];
long long lazy[4 * 200010];
void build_seg(int low, int high, int pos) {
  if (low == high) {
    segtree[pos] = inp[low];
    return;
  }
  int mid = (low + high) / 2;
  build_seg(mid + 1, high, 2 * pos + 1);
  build_seg(low, mid, 2 * pos);
  segtree[pos] = min(segtree[2 * pos + 1], segtree[2 * pos]);
}
long long RMQ(int qlow, int qhigh, int low, int high, int pos) {
  if (lazy[pos] != 0) {
    segtree[pos] += lazy[pos];
    if (high != low) lazy[2 * pos] += lazy[pos], lazy[2 * pos + 1] += lazy[pos];
    lazy[pos] = 0;
  }
  if (high < qlow || low > qhigh || low > high) return 1e9;
  if (qlow <= low && qhigh >= high) return segtree[pos];
  int mid = (low + high) / 2;
  return min(RMQ(qlow, qhigh, low, mid, pos * 2),
             RMQ(qlow, qhigh, mid + 1, high, pos * 2 + 1));
}
void lazy_p(int x, int y, int val, int low, int high, int pos) {
  if (lazy[pos] != 0) {
    segtree[pos] += lazy[pos];
    if (low != high) lazy[pos * 2] += lazy[pos], lazy[pos * 2 + 1] += lazy[pos];
    lazy[pos] = 0;
  }
  if (x > high || y < low || low > high) return;
  if (x <= low && y >= high) {
    lazy[pos] += val;
    segtree[pos] += lazy[pos];
    if (low != high) lazy[pos * 2] += lazy[pos], lazy[pos * 2 + 1] += lazy[pos];
    lazy[pos] = 0;
    return;
  }
  int mid = (low + high) / 2;
  lazy_p(x, y, val, low, mid, pos * 2);
  lazy_p(x, y, val, mid + 1, high, pos * 2 + 1);
  segtree[pos] = min(segtree[pos * 2 + 1], segtree[pos * 2]);
}
int main() {
  int n, m;
  cin >> n;
  fill(segtree, segtree + 4 * 200010, 1e9);
  for (int i = 0; i < n; i++) {
    scanf("%d", &inp[i]);
  }
  long long cnt = 0;
  build_seg(0, n - 1, 1);
  cin >> m;
  for (int i = 0; i < m; i++) {
    cnt = 0;
    int x, y;
    char s[10];
    cin >> x >> y;
    gets(s);
    if (strlen(s) != 0) {
      long long z = atoi(s);
      if (x > y) {
        lazy_p(0, y, z, 0, n - 1, 1);
        lazy_p(x, n - 1, z, 0, n - 1, 1);
      } else
        lazy_p(x, y, z, 0, n - 1, 1);
    } else {
      if (x > y) {
        long long rmq = min(RMQ(x, n - 1, 0, n - 1, 1), RMQ(0, y, 0, n - 1, 1));
        printf("%I64d\n", rmq);
      } else
        printf("%I64d\n", RMQ(x, y, 0, n - 1, 1));
    }
  }
}
