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 var;
class segTree {
  int i;
  int *arr;
  long long int *ans, *lazy;

 public:
  segTree(int n) {
    arr = new int[n + 1];
    ans = new long long int[4 * n];
    lazy = new long long int[4 * n];
    for (i = 1; i < 4 * n; i++) ans[i] = 1000000000, lazy[i] = 0;
    i = 1;
  }
  void input(int x) {
    arr[i] = x;
    i++;
  }
  void build(int at, int l, int r) {
    ans[at] = 1000000000;
    if (l == r) {
      ans[at] = arr[l];
      return;
    }
    int mid = (l + r) / 2;
    build(at * 2, l, mid);
    build(at * 2 + 1, mid + 1, r);
    ans[at] = min(ans[at * 2], ans[at * 2 + 1]);
  }
  long long int query(int at, int l, int r, int L, int R) {
    if (lazy[at] != 0) {
      ans[at] += lazy[at];
      if (l != r) {
        lazy[at * 2] += lazy[at];
        lazy[at * 2 + 1] += lazy[at];
      }
      lazy[at] = 0;
    }
    if (l > r || l > R || L > r) return 1000000000;
    if (l >= L && r <= R) {
      return ans[at];
    }
    int mid = (l + r) / 2;
    long long int x = query(at * 2, l, mid, L, R);
    long long int y = query(at * 2 + 1, mid + 1, r, L, R);
    return min(x, y);
  }
  void update(int at, int l, int r, int L, int R, long long int u) {
    if (lazy[at] != 0) {
      ans[at] += lazy[at];
      if (l != r) {
        lazy[at * 2] += lazy[at];
        lazy[at * 2 + 1] += lazy[at];
      }
      lazy[at] = 0;
    }
    if (l > r || l > R || r < L) return;
    if (l >= L && r <= R) {
      ans[at] += u;
      if (l != r) {
        lazy[at * 2] += u;
        lazy[at * 2 + 1] += u;
      }
      return;
    }
    int mid = (l + r) / 2;
    update(at * 2, l, mid, L, R, u);
    update(at * 2 + 1, mid + 1, r, L, R, u);
    ans[at] = min(ans[at * 2], ans[at * 2 + 1]);
  }
};
int main() {
  int i, j, k;
  int n, x, m;
  int l, r;
  scanf("%d", &n);
  segTree s(n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    s.input(x);
  }
  s.build(1, 1, n);
  scanf("%d", &m);
  while (m >= 0) {
    m--;
    string str;
    vector<int> v;
    getline(cin, str);
    stringstream ss(str);
    while (ss >> var) v.push_back(var);
    if (v.size() == 0) continue;
    l = v[0] + 1;
    r = v[1] + 1;
    if (v.size() == 3) {
      x = v[2];
      if (l <= r)
        s.update(1, 1, n, l, r, x);
      else {
        s.update(1, 1, n, l, n, x);
        s.update(1, 1, n, 1, r, x);
      }
    } else if (v.size() == 2) {
      if (l > r)
        cout << min(s.query(1, 1, n, l, n), s.query(1, 1, n, 1, r)) << endl;
      else
        cout << s.query(1, 1, n, l, r) << endl;
    }
  }
  return 0;
}
