#include <bits/stdc++.h>
using namespace std;
int minp[100005], minn[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int q;
  cin >> q;
  for (int i = 1; i <= 100000; i++) minp[i] = minn[i] = 1000000009;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, k;
      cin >> l >> r >> k;
      bool s = (k > 0);
      k = abs(k);
      if (s == 0)
        for (int i = l; i < r; i++) minn[i] = min(minn[i], k);
      else
        for (int i = l; i < r; i++) minp[i] = min(minp[i], k);
    } else {
      int l, r;
      cin >> l >> r;
      long long int tot = 0;
      for (int i = l; i < r; i++)
        if (minp[i] != 1000000009 && minn[i] != 1000000009)
          tot += minp[i] + minn[i];
      cout << tot << '\n';
    }
  }
}
