#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lint = long long; const lint INF = 100100100100100; // quoted from beet-aizu template struct LazySegmentTree{ //using F = function; //using G = function; //using H = function; int n,height; F f; G g; H h; T ti; E ei; vector dat; vector laz; LazySegmentTree(F f,G g,H h,T ti,E ei): f(f),g(g),h(h),ti(ti),ei(ei){} void init(int n_){ n=1;height=0; while(n &v){ int n_=v.size(); init(n_); for(int i=0;i>i); } inline void recalc(int k){ while(k>>=1) dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1)); } void update(int a,int b,E x){ thrust(a+=n); thrust(b+=n-1); for(int l=a,r=b+1;l>=1,r>>=1){ if(l&1) laz[l]=h(laz[l],x),l++; if(r&1) --r,laz[r]=h(laz[r],x); } recalc(a); recalc(b); } void set_val(int a,T x){ thrust(a+=n); dat[a]=x;laz[a]=ei; recalc(a); } T query(int a,int b){ thrust(a+=n); thrust(b+=n-1); T vl=ti,vr=ti; for(int l=a,r=b+1;l>=1,r>>=1) { if(l&1) vl=f(vl,reflect(l++)); if(r&1) vr=f(reflect(--r),vr); } return f(vl,vr); } }; signed main(){ lint n; cin >> n; auto f = [](lint a, lint b){ return min(a, b); }; auto g = [](lint a, lint b){ return a + b; }; auto h = [](lint a, lint b){ return a + b; }; LazySegmentTree sg(f, g, h, INF, 0); vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sg.build(a); int q; cin >> q; for (int i = 0; i < q; i++) { lint k, l, r, c; cin >> k >> l >> r >> c; if (k == 1) { sg.update(l - 1, r, c); } else { cout << sg.query(l - 1, r) << endl; } } return 0; }