#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
template <typename T1, typename T2>
bool cmin(T1 &a, const T2 &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
bool cmax(T1 &a, const T2 &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
const int MAXN = 1e5;
signed main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  vector<unsigned> pos(MAXN), neg(MAXN);
  for (; q; q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, k;
      cin >> l >> r >> k;
      l--;
      r--;
      unsigned *data = (k > 0 ? pos.data() : neg.data());
      unsigned b = abs(k) - 1;
      for (int i = l; i < r; i++) {
        unsigned a = data[i] - 1;
        data[i] = (a < b ? a : b) + 1;
      }
    } else {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      long long ans = 0;
      for (int i = l; i < r; i++)
        ans += (pos[i] + neg[i]) &
               ~(((int)(pos[i] - 1) >> 31) | ((int)(neg[i] - 1) >> 31));
      cout << ans << endl;
    }
  }
}
