#include #include using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=14449999999999994; ll mod=1000000007; using S = long long; using F = long long; const S INF = 8e18; S op(S a, S b){ return std::min(a, b); } S e(){ return INF; } S mapping(F f, S x){ return f+x; } F composition(F f, F g){ return f+g; } F id(){ return 0; } int main(){ ll n; cin >> n; vectora(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } ll q; cin >> q; lazy_segtreeseg(a); vectorans; for (ll i = 0; i < q; i++) { ll k,l,r,c; cin >> k >> l >> r >> c; l--,r; if (k==1) { seg.apply(l,r,c); }else{ ans.push_back(seg.prod(l,r)); } } for (ll i = 0; i < ans.size(); i++) { cout << ans[i] << endl; } }