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 segMin[1 << 19], segAdd[1 << 19];
int n;
void add(int a, int b, int x, int k = 0, int l = 0, int r = n) {
  if (r <= a || b <= l) return;
  if (a <= l && r <= b) {
    segAdd[k] += x;
    while (k) {
      k = (k - 1) / 2;
      segMin[k] = min(segMin[k * 2 + 1] + segAdd[k * 2 + 1],
                      segMin[k * 2 + 2] + segAdd[k * 2 + 2]);
    }
    return;
  }
  add(a, b, x, k * 2 + 1, l, (l + r) / 2);
  add(a, b, x, k * 2 + 2, (l + r) / 2, r);
}
long long getMin(int a, int b, int k = 0, int l = 0, int r = n) {
  if (r <= a || b <= l) return (LLONG_MAX);
  if (a <= l && r <= b) return (segMin[k] + segAdd[k]);
  long long left = getMin(a, b, k * 2 + 1, l, (l + r) / 2);
  long long right = getMin(a, b, k * 2 + 2, (l + r) / 2, r);
  return (min(left, right) + segAdd[k]);
}
int main(int argc, char const* argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    add(i, i + 1, t);
  }
  int m;
  scanf("%d", &m);
  getchar();
  for (int i = 0; i < m; i++) {
    int arg[3];
    char query[256], *p;
    int idx = 0;
    fgets(query, 256, stdin);
    p = strtok(query, " \n");
    while (p != NULL) {
      arg[idx++] = atoi(p);
      p = strtok(NULL, " \n");
    }
    if (idx == 2) {
      printf("%lld\n", arg[0] <= arg[1]
                           ? getMin(arg[0], arg[1] + 1)
                           : min(getMin(arg[0], n), getMin(0, arg[1] + 1)));
    } else {
      if (arg[0] <= arg[1]) {
        add(arg[0], arg[1] + 1, arg[2]);
      } else {
        add(arg[0], n, arg[2]);
        add(0, arg[1] + 1, arg[2]);
      }
    }
  }
  return 0;
}
