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 int n, q, arr[200005], sqr[500], grupsize, grupno, grupcnt, mins, ans,
    upd[500];
void update(long long int left, long long int right, long long int value) {
  long long int lgrup = (left / grupsize + (left % grupsize > 0));
  long long int rgrup = (right / grupsize + (right % grupsize > 0));
  if (rgrup == lgrup) {
    for (int i = left; i <= right; i++) {
      arr[i] += value;
      sqr[lgrup] = min(sqr[lgrup], arr[i]);
    }
    sqr[lgrup] = LLONG_MAX;
    for (int i = (rgrup - 1) * grupsize + 1; i <= rgrup * grupsize; i++)
      sqr[lgrup] = min(sqr[lgrup], arr[i]);
  } else {
    for (int i = lgrup + 1; i < rgrup; i++) upd[i] += value;
    for (int i = left; i <= lgrup * grupsize; i++) arr[i] += value;
    for (int i = (rgrup - 1) * grupsize + 1; i <= right; i++) arr[i] += value;
    sqr[lgrup] = LLONG_MAX;
    for (int i = (lgrup - 1) * grupsize + 1; i <= lgrup * grupsize; i++)
      sqr[lgrup] = min(sqr[lgrup], arr[i]);
    sqr[rgrup] = LLONG_MAX;
    for (int i = (rgrup - 1) * grupsize + 1; i <= rgrup * grupsize; i++)
      sqr[rgrup] = min(sqr[rgrup], arr[i]);
  }
}
long long int query(long long int left, long long int right) {
  long long int lgrup = (left / grupsize + (left % grupsize > 0));
  long long int rgrup = (right / grupsize + (right % grupsize > 0));
  ans = LLONG_MAX;
  if (rgrup == lgrup) {
    for (int i = left; i <= right; i++) {
      ans = min(ans, arr[i] + upd[lgrup]);
    }
  } else {
    for (int i = lgrup + 1; i < rgrup; i++) ans = min(ans, sqr[i] + upd[i]);
    for (int i = left; i <= lgrup * grupsize; i++)
      ans = min(ans, arr[i] + upd[lgrup]);
    for (int i = (rgrup - 1) * grupsize + 1; i <= right; i++)
      ans = min(ans, arr[i] + upd[rgrup]);
  }
  return ans;
}
void solve() {
  cin >> n;
  grupcnt = (long long int)sqrt(n);
  grupsize = (long long int)ceil(sqrt(n));
  grupno = 1;
  mins = LLONG_MAX;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    mins = min(arr[i], mins);
    if (i % grupsize == 0) {
      sqr[grupno] = mins;
      mins = LLONG_MAX;
      grupno++;
    }
  }
  cin >> q;
  string s;
  getline(std::cin, s);
  while (q--) {
    int l, r, val = -999999999;
    getline(std::cin, s);
    istringstream iss(s);
    iss >> l >> r >> val;
    l++;
    r++;
    if (val == 0) continue;
    if (val == -999999999) {
      if (l == r) {
        cout << arr[l] + upd[(l / grupsize + (l % grupsize > 0))] << endl;
        continue;
      } else {
        long long int c = LLONG_MAX;
        if (l <= r)
          c = min(c, query(l, r));
        else {
          c = min(c, query(1, r));
          c = min(c, query(l, n));
        }
        cout << c << endl;
      }
    } else {
      if (l <= r)
        update(l, r, val);
      else {
        update(1, r, val);
        update(l, n, val);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
