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;
int a[200005];
int start, stop, val;
char s[1000];
struct info {
  int mn, p;
} tree[4 * 200005];
void Build(int n, int b, int e) {
  if (b == e) {
    tree[n].mn = a[b];
    tree[n].p = 0;
    return;
  }
  int l = n * 2;
  int r = n * 2 + 1;
  int m = (b + e) / 2;
  Build(l, b, m);
  Build(r, m + 1, e);
  tree[n].mn = min(tree[l].mn, tree[r].mn);
}
void Update(int n, int b, int e, int x, int y, int v) {
  if (b > y || e < x) return;
  if (b >= x && e <= y) {
    tree[n].mn += v;
    tree[n].p += v;
    return;
  }
  int l = n * 2;
  int r = n * 2 + 1;
  int m = (b + e) / 2;
  Update(l, b, m, x, y, v);
  Update(r, m + 1, e, x, y, v);
  tree[n].mn = min(tree[l].mn, tree[r].mn) + tree[n].p;
}
int Find(int n, int b, int e, int x, int y, int cary) {
  if (b > y || e < x) return 1000000000;
  if (b >= x && e <= y) {
    return tree[n].mn + cary;
  }
  int l = n * 2;
  int r = n * 2 + 1;
  int m = (b + e) / 2;
  int f1 = Find(l, b, m, x, y, cary + tree[n].p);
  int f2 = Find(r, m + 1, e, x, y, cary + tree[n].p);
  return min(f1, f2);
}
void process() {
  int len = strlen(s);
  s[len] = ' ';
  int i = 0, f, n;
  n = f = 0;
  while (s[i] == ' ' && i <= len) i++;
  while (s[i] != ' ' && i <= len) {
    n = (10 * n) + (s[i] - '0');
    f = 1;
    i++;
  }
  if (f) start = n;
  n = f = 0;
  while (s[i] == ' ' && i <= len) i++;
  while (s[i] != ' ' && i <= len) {
    n = (10 * n) + (s[i] - '0');
    f = 1;
    i++;
  }
  if (f) stop = n;
  n = f = 0;
  int sign = 0;
  while (s[i] == ' ' && i <= len) i++;
  if (s[i] == '-') sign = 1, i++;
  while (s[i] != ' ' && i <= len) {
    n = (10 * n) + (s[i] - '0');
    f = 1;
    i++;
  }
  if (sign) n = -n;
  if (f) val = n;
}
int main() {
  int n, q, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  Build(1, 1, n);
  scanf("%d", &q);
  getchar();
  while (q--) {
    gets(s);
    start = stop = val = -1000000000;
    process();
    start++;
    stop++;
    if (val != -1000000000) {
      if (start <= stop)
        Update(1, 1, n, start, stop, val);
      else {
        Update(1, 1, n, start, n, val);
        Update(1, 1, n, 1, stop, val);
      }
    } else {
      int ans;
      if (start <= stop)
        ans = Find(1, 1, n, start, stop, 0);
      else
        ans = min(Find(1, 1, n, start, n, 0), Find(1, 1, n, 1, stop, 0));
      printf("%d\n", ans);
    }
  }
  return 0;
}
