#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 5;
int mn[MAXN << 1], mx[MAXN << 1];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  bool has = 0;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, k;
      cin >> l >> r >> k;
      has = 1;
      if (k < 0) {
        k = -k;
        for (int i = l; i < r; i++) mn[i] = (!mn[i] || mn[i] > k) ? k : mn[i];
      } else {
        for (int i = l; i < r; i++) mx[i] = (!mx[i] || mx[i] > k) ? k : mx[i];
      }
    } else {
      int l, r;
      cin >> l >> r;
      if (!has) {
        cout << "0\n";
        continue;
      }
      long long ans = 0;
      for (int i = l; i < r; i++) ans += mn[i] && mx[i] ? mx[i] + mn[i] : 0;
      cout << ans << '\n';
    }
  }
}
