#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++) #define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++) #define ALL(x) x.begin(), x.end() using ll = long long; using namespace std; #include using namespace atcoder; ll op(ll a, ll b){ return min(a, b); } ll mapping(ll f, ll x){ return f+x; } ll composition(ll f, ll g){ return f+g; } ll e(){ return (ll)1e18; } ll id(){ return (ll) 0; } int main(){ int n; cin >> n; vector a(n); rep(i, n) cin >> a.at(i); lazy_segtree lsg(a); int q; cin >> q; rep(_q, q){ ll k, l, r, c; cin >> k >> l >> r >> c; if(k == 1){ lsg.apply(l-1, r, c); }else{ cout << lsg.prod(l-1, r) << endl; } } return 0; }