#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
using namespace std;
using ll = long long;
const ll N = 1e5 + 5;
int q, mnp[N], mnn[N];
int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> q;
  memset(mnp, 0x3f, sizeof mnp);
  memset(mnn, 0x3f, sizeof mnn);
  while (q--) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      int k;
      cin >> k;
      if (k > 0) {
        while (r-- > l) {
          mnp[r] = min(mnp[r], k);
        }
      } else {
        k *= -1;
        while (r-- > l) {
          mnn[r] = min(mnn[r], k);
        }
      }
    } else {
      ll ans = 0;
      while (r-- > l) {
        if (mnp[r] <= 1e9 && mnn[r] <= 1e9) {
          ans += mnp[r] + mnn[r];
        }
      }
      cout << ans << '\n';
    }
  }
}
