#include using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define rep2(i, x, n) for(int i = x; i <= n; i++) #define rep3(i, x, n) for(int i = x; i >= n; i--) #define elif else if #define sp(x) fixed << setprecision(x) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using ll = long long; using pii = pair; using pil = pair; using pli = pair; using pll = pair; const int MOD = 1000000007; //const int MOD = 998244353; const int inf = (1<<30)-1; const ll INF = (1LL<<60)-1; const double pi = acos(-1.0); const double EPS = 1e-10; template bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;}; template bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;}; template struct Node{ const int l, r; T base, m; vector v; void update(){ m = e; for(auto &u: v) chmin(m, u); } Node(vector a, int l, int r) : l(l), r(r), base(0){ rep2(i, l, r-1) v.pb(a[i]); update(); } void add(int a, int b, T x){ if(a >= r || b <= l) return; if(a <= l && b >= r) {base += x; return;} rep2(i, max(a, l), min(b, r)-1) v[i-l] += x; update(); } T query(int a, int b){ if(a >= r || b <= l) return e; if(a <= l && b >= r) return base+m; T ret = e; rep2(i, max(a, l), min(b, r)-1) chmin(ret, v[i-l]); return base+ret; } }; int main(){ int N; cin >> N; vector a(N); rep(i, N) cin >> a[i]; vector> nodes; int n = 0; while(n*n < N) n++; rep(i, n){ nodes.eb(a, min(N, n*i), min(N, n*(i+1))); } int Q; cin >> Q; while(Q--){ int k, l, r; ll c; cin >> k >> l >> r >> c; l--; if(k == 1){ for(auto &e: nodes) e.add(l, r, c); } else{ ll ret = INF; for(auto &e: nodes) chmin(ret, e.query(l, r)); cout << ret << endl; } } }