#include #include using namespace std; using ll = long long; //取得: 区間min/ 更新: 区間加算 template class RMSQ { public: static T op(T l, T r) {return min(l, r);} //区間取得の演算 static T e(){return (T)1e16;} //区間取得の単位元 static T map(T n, T v) {return n + v;} static T comp(T n, T v) {return v + n;} static T id(){return 0;} //遅延配列の単位元 }; int main() { int n; cin >> n; vector a(n); for(int i = 0; i < n; i++)cin >> a[i]; atcoder::lazy_segtree::op, RMSQ::e, ll, RMSQ::map, RMSQ::comp, RMSQ::id> tree(a); int q; cin >> q; while(q--) { ll k, l, r, v; cin >> k >> l >> r >> v; if(k == 1) { tree.apply(l - 1, r, v); } else { cout << tree.prod(l - 1, r) << endl; } } }