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 a[800010], tag[800010], b[200010];
int n, m, tp;
inline long long read_long() {
  tp = 0;
  long long t = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  if (ch == ' ') tp = 1;
  return x * t;
}
inline int read_int() {
  tp = 0;
  int t = 1, x = 0;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  if (ch == ' ') tp = 1;
  return x * t;
}
inline void print() {
  for (int i = 1; i < n << 2; i++) {
    printf("id=%d min=%lld tag=%d lc=%d rc=%d\n", i, a[i], tag[i], i << 1,
           i << 1 | 1);
  }
}
inline void build(int x, int l, int r) {
  a[x] = 0;
  if (l == r) {
    a[x] = b[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  a[x] = min(a[x << 1], a[x << 1 | 1]);
}
inline void change(int x, int l, int r, int ll, int rr, long long num) {
  if (l <= ll && rr <= r) {
    tag[x] += num;
    return;
  }
  if (ll > r || l > rr) return;
  int mid = (ll + rr) >> 1;
  if (l <= mid) change(x << 1, l, r, ll, mid, num);
  if (mid < r) change(x << 1 | 1, l, r, mid + 1, rr, num);
  a[x] = min(a[x << 1] + tag[x << 1], a[x << 1 | 1] + tag[x << 1 | 1]);
}
inline int query(int x, int l, int r, int ll, int rr) {
  if (r < ll || rr < l) return INT_MAX;
  if (ll <= l && r <= rr) {
    return a[x] + tag[x];
  }
  int mid = (l + r) >> 1;
  long long u = LONG_LONG_MAX, v = LONG_LONG_MAX;
  if (ll <= mid) u = query(x << 1, l, mid, ll, rr);
  if (mid < rr) v = query(x << 1 | 1, mid + 1, r, ll, rr);
  return min(u, v) + tag[x];
}
int main() {
  n = read_int();
  for (int i = 1; i <= n; i++) b[i] = read_long();
  for (int i = 1; i < n << 2; i++) a[i] = LONG_LONG_MAX;
  build(1, 1, n);
  m = read_int();
  while (m--) {
    int ll = read_int() + 1, rr = read_int() + 1;
    if (tp) {
      long long x = read_long();
      if (ll > rr) {
        change(1, ll, n, 1, n, x);
        change(1, 1, rr, 1, n, x);
      } else
        change(1, ll, rr, 1, n, x);
    } else {
      long long ans;
      if (ll > rr)
        ans = min(query(1, 1, n, ll, n), query(1, 1, n, 1, rr));
      else
        ans = query(1, 1, n, ll, rr);
      printf("%lld\n", ans);
    }
  }
  return 0;
}
