#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
long long tree[4 * N], lazy[4 * N], n, a[N];
void build(int n, int l, int r) {
  if (l == r) {
    tree[n] = a[l];
    return;
  }
  int m = (l + r) / 2;
  build(n * 2, l, m);
  build(n * 2 + 1, m + 1, r);
  tree[n] = min(tree[n * 2], tree[n * 2 + 1]);
}
void update(int n, int l, int r, long long val, int x, int y) {
  if (lazy[n]) {
    tree[n] += lazy[n];
    if (l != r) {
      lazy[n * 2] += lazy[n];
      lazy[n * 2 + 1] += lazy[n];
    }
    lazy[n] = 0;
  }
  if (l > y || r < x || x > y) return;
  if (x <= l && r <= y) {
    tree[n] += val;
    if (l != r) {
      lazy[n * 2] += val;
      lazy[n * 2 + 1] += val;
    }
    return;
  }
  int m = (l + r) / 2;
  update(n * 2, l, m, val, x, y);
  update(n * 2 + 1, m + 1, r, val, x, y);
  tree[n] = min(tree[n * 2], tree[n * 2 + 1]);
}
long long query(int n, int l, int r, int x, int y) {
  if (lazy[n]) {
    tree[n] += lazy[n];
    if (l != r) {
      lazy[n * 2] += lazy[n];
      lazy[n * 2 + 1] += lazy[n];
    }
    lazy[n] = 0;
  }
  if (l > y || r < x || x > y) return 1e18;
  if (x <= l && r <= y) return tree[n];
  int m = (l + r) / 2;
  long long c1 = query(n * 2, l, m, x, y);
  long long c2 = query(n * 2 + 1, m + 1, r, x, y);
  return min(c1, c2);
}
vector<int> v;
void take_input() {
  stringstream ss;
  string str;
  getline(cin, str);
  replace(str.begin(), str.end(), ',', ' ');
  ss << str;
  int x = 0;
  while (ss >> x) {
    v.push_back(x);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  build(1, 0, n - 1);
  int q;
  cin >> q;
  cin.ignore();
  while (q-- > 0) {
    int x, y, c, val;
    take_input();
    x = v[0], y = v[1];
    if (v.size() == 2) {
      if (x > y) {
        cout << min(query(1, 0, n - 1, x, n - 1), query(1, 0, n - 1, 0, y))
             << endl;
      } else {
        cout << query(1, 0, n - 1, x, y) << endl;
      }
    } else {
      val = v[2];
      if (x > y) {
        update(1, 0, n - 1, val, x, n - 1);
        update(1, 0, n - 1, val, 0, y);
      } else {
        update(1, 0, n - 1, val, x, y);
      }
    }
    v.clear();
  }
}
