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 n, m;
long long nums[200005];
struct segtree {
  int l, r;
  segtree *lChild, *rChild;
  long long val;
  long long prop = 0;
  segtree(int l, int r) {
    this->l = l;
    this->r = r;
    if (l == r) {
      val = nums[l];
      return;
    }
    int mid = (l + r) / 2;
    lChild = new segtree(l, mid);
    rChild = new segtree(mid + 1, r);
    val = min(lChild->val, rChild->val);
  }
  void update(int lRange, int rRange, long long amt) {
    if (l > rRange || r < lRange) return;
    if (l >= lRange && r <= rRange) {
      prop += amt;
      return;
    }
    propagate();
    lChild->update(lRange, rRange, amt);
    rChild->update(lRange, rRange, amt);
    val = min(lChild->val + lChild->prop, rChild->val + rChild->prop);
  }
  long long rmq(int lRange, int rRange) {
    if (l > rRange || r < lRange) return 9223372036854775807L;
    propagate();
    if (l >= lRange && r <= rRange) return val;
    return min(lChild->rmq(lRange, rRange), rChild->rmq(lRange, rRange));
  }
  void propagate() {
    if (prop == 0) return;
    val += prop;
    if (l != r) {
      lChild->prop += prop;
      rChild->prop += prop;
    }
    prop = 0;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
  }
  cin >> m;
  string line;
  getline(cin, line);
  struct segtree second(0, n - 1);
  for (int i = 0; i < m; i++) {
    vector<int> nums;
    getline(cin, line);
    stringstream ss(line);
    int x;
    while (ss >> x) nums.push_back(x);
    if (nums.size() == 3) {
      if (nums[2] == 0) continue;
      if (nums[0] <= nums[1]) {
        second.update(nums[0], nums[1], nums[2]);
      } else {
        second.update(nums[0], n - 1, nums[2]);
        second.update(0, nums[1], nums[2]);
      }
    } else {
      if (nums[0] <= nums[1]) {
        cout << second.rmq(nums[0], nums[1]) << "\n";
      } else {
        cout << (min(second.rmq(nums[0], n - 1), second.rmq(0, nums[1])))
             << "\n";
      }
    }
  }
}
