#include using namespace std; typedef long long ll; typedef pair P; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0) templateostream& operator<<(ostream& os,const pair& a) {os << "(" << a.first << ", " << a.second << ")";return os;} const char newl = '\n'; struct LazySegmentTree { private: int n; vector node,lazy; public: LazySegmentTree(vector v) { int sz = v.size(); n = 1; while (n < sz) n *= 2; node.resize(2*n-1); lazy.resize(2*n-1,0); for (int i = 0;i < sz;++i) node[i+n-1] = v[i]; for (int i = n-2;i >= 0;--i) node[i] = min(node[i*2+1],node[i*2+2]); } void eval(int k,int l,int r) { if (lazy[k] != 0) { node[k] += lazy[k]/(r-l); if (r-l > 1) { lazy[2*k+1] += lazy[k]/2; lazy[2*k+2] += lazy[k]/2; } lazy[k] = 0; } } void add(int a,int b,ll x,int k = 0,int l = 0,int r = -1) { if (r < 0) r = n; eval(k,l,r); if (b <= l || r <= a) return; if (a <= l && r <= b) { lazy[k] += (r-l)*x; eval(k,l,r); } else { add(a,b,x,2*k+1,l,(l+r)/2); add(a,b,x,2*k+2,(l+r)/2,r); node[k] = min(node[2*k+1],node[2*k+2]); } } ll getmin(int a,int b,int k = 0,int l = 0,int r = -1) { if (r < 0) r = n; if (b <= l || r <= a) return INT64_MAX; eval(k,l,r); if (a <= l && r <= b) return node[k]; ll vl = getmin(a,b,k*2+1,l,(l+r)/2); ll vr = getmin(a,b,2*k+2,(l+r)/2,r); return min(vl,vr); } }; int main() { int n; cin >> n; vector a(n); for (int i = 0;i < n;++i) cin >> a[i]; LazySegmentTree seg(a); int q; cin >> q; while (q--) { int k,l,r;ll c; cin >> k >> l >> r >> c; if (k == 1) seg.add(l-1,r,c); else cout << seg.getmin(l-1,r) << newl; } }