#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const long long INF = 1e18;
const long long MAXN = 100000;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
int main() {
  int Q;
  while (cin >> Q) {
    vector<uint32_t> pos(100000), neg(100000);
    for (int ii = 0; ii < Q; ++ii) {
      int ty;
      cin >> ty;
      if (ty == 1) {
        int L;
        int R;
        int k;
        cin >> L >> R >> k;
        --L, --R;
        uint32_t *data = k > 0 ? pos.data() : neg.data();
        uint32_t b = abs(k) - 1;
        for (long long x = (L); x < (R); ++x) {
          auto a = data[x] - 1;
          data[x] = (a < b ? a : b) + 1;
        }
      } else if (ty == 2) {
        int L;
        int R;
        cin >> L >> R;
        --L, --R;
        long long ans = 0;
        for (long long x = (L); x < (R); ++x) {
          ans += (pos[x] + neg[x]) & ~(((int32_t)(pos[x] - 1) >> 31) |
                                       ((int32_t)(neg[x] - 1) >> 31));
        }
        cout << ans << '\n';
      } else
        return 0;
    }
  }
  return 0;
}
