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 tree[4 * 200010];
long long lazy[4 * 200010];
long long arr[200010];
void doLazy(int i, long long l, long long r) {
  if (lazy[i] != 0) {
    tree[i] += lazy[i];
    if (l != r) {
      lazy[i << 1] += lazy[i];
      lazy[i << 1 | 1] += lazy[i];
    }
    lazy[i] = 0;
  }
}
long long query(int i, int l, int r, int x, int y) {
  doLazy(i, l, r);
  if (l >= x && r <= y)
    return tree[i];
  else if (r < x || l > y)
    return (long long)1e12;
  else {
    int mid = (l + r) >> 1;
    return min(query(i << 1, l, mid, x, y),
               query(i << 1 | 1, mid + 1, r, x, y));
  }
}
void update(int i, int l, int r, int x, int y, long long v) {
  doLazy(i, l, r);
  if (l >= x && r <= y) {
    lazy[i] = v;
    doLazy(i, l, r);
  } else if (r < x || l > y)
    return;
  else {
    int mid = (l + r) >> 1;
    update(i << 1, l, mid, x, y, v);
    update(i << 1 | 1, mid + 1, r, x, y, v);
    tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
  }
}
void build(int i, int l, int r) {
  if (l == r)
    tree[i] = arr[l];
  else {
    int mid = (l + r) >> 1;
    build(i << 1, l, mid);
    build(i << 1 | 1, mid + 1, r);
    tree[i] = min(tree[i << 1], tree[i << 1 | 1]);
  }
}
vector<long long> tokenize(string s) {
  vector<string> sts;
  sts.push_back("");
  int i = 0;
  for (char c : s) {
    if (c == ' ') {
      sts.push_back("");
      i++;
    } else {
      sts[i] += c;
    }
  }
  vector<long long> nums;
  for (string st : sts) {
    if (st != "") {
      nums.push_back(stoi(st));
    }
  }
  return nums;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  build(1, 1, n);
  int m;
  cin >> m;
  while (m--) {
    string q = "";
    while (q == "") getline(cin, q, '\n');
    vector<long long> nums = tokenize(q);
    int lf = nums[0] + 1;
    int rg = nums[1] + 1;
    if (nums.size() == 2) {
      if (lf > rg) {
        int l1 = lf;
        int l2 = 1;
        int r1 = n;
        int r2 = rg;
        long long ans = min(query(1, 1, n, l1, r1), query(1, 1, n, l2, r2));
        cout << ans << endl;
      } else {
        long long ans = query(1, 1, n, lf, rg);
        cout << ans << endl;
      }
    } else if (nums.size() == 3) {
      long long v = nums[2];
      if (lf > rg) {
        int l1 = lf;
        int l2 = 1;
        int r1 = n;
        int r2 = rg;
        update(1, 1, n, l1, r1, v);
        update(1, 1, n, l2, r2, v);
      } else {
        update(1, 1, n, lf, rg, v);
      }
    }
  }
}
