#include <bits/stdc++.h>
using namespace std;
int n, m;
long long data[(1 << 19)];
long long lazy[(1 << 19)];
void upd(int l, int r, int x, int k, int a, int b) {
  if (l <= a && b <= r) {
    lazy[k] += x;
    return;
  }
  if (l >= b || a >= r) return;
  if (lazy[k]) {
    lazy[k * 2 + 1] += lazy[k];
    lazy[k * 2 + 2] += lazy[k];
    lazy[k] = 0;
  }
  upd(l, r, x, k * 2 + 1, a, (a + b) / 2);
  upd(l, r, x, k * 2 + 2, (a + b) / 2, b);
  data[k] =
      min(data[k * 2 + 1] + lazy[k * 2 + 1], data[k * 2 + 2] + lazy[k * 2 + 2]);
}
long long ans(int l, int r, int k, int a, int b) {
  if (l <= a && b <= r) {
    return data[k] + lazy[k];
  }
  if (l >= b || a >= r) return (long long)1e18;
  if (lazy[k]) {
    lazy[k * 2 + 1] += lazy[k];
    lazy[k * 2 + 2] += lazy[k];
    lazy[k] = 0;
  }
  long long ret = min(ans(l, r, k * 2 + 1, a, (a + b) / 2),
                      ans(l, r, k * 2 + 2, (a + b) / 2, b));
  data[k] =
      min(data[k * 2 + 1] + lazy[k * 2 + 1], data[k * 2 + 2] + lazy[k * 2 + 2]);
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = 0; i < (1 << 19); i++) data[i] = (long long)1e18;
  scanf("%d", &m);
  n = 1;
  while (n < m) n *= 2;
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    data[i + n - 1] = 0;
    upd(i, i + 1, x, 0, 0, n);
  }
  scanf("%d", &m);
  char s[222222];
  gets(s);
  for (int i = 0; i < m; i++) {
    gets(s);
    vector<int> ip;
    int x;
    stringstream haha;
    haha << s;
    while (haha >> x) ip.push_back(x);
    if (ip.size() == 2) {
      if (ip[0] <= ip[1])
        printf("%I64d\n", ans(ip[0], ip[1] + 1, 0, 0, n));
      else
        printf("%I64d\n",
               min(ans(0, ip[1] + 1, 0, 0, n), ans(ip[0], n, 0, 0, n)));
    } else {
      if (ip[0] <= ip[1])
        upd(ip[0], ip[1] + 1, ip[2], 0, 0, n);
      else
        upd(0, ip[1] + 1, ip[2], 0, 0, n), upd(ip[0], n, ip[2], 0, 0, n);
    }
  }
  return 0;
}
