#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
inline int ifnotzero(int num) { return ~((num - 1) >> 31); }
int Q, t, L, R, k;
int data[2][100005];
int main() {
  std::ios::sync_with_stdio(false);
  cin >> Q;
  while (Q--) {
    cin >> t;
    if (t == 1) {
      cin >> L >> R >> k;
      bool idx = k > 0;
      int dt = abs(k);
      for (int i = L; i < R; ++i) {
        uint32_t a = data[idx][i] - 1;
        data[idx][i] = (a < dt - 1) ? a + 1 : dt;
      }
    } else {
      cin >> L >> R;
      long long res = 0;
      for (int i = L; i < R; ++i)
        res += (data[0][i] + data[1][i]) & ifnotzero(data[1][i]) &
               ifnotzero(data[0][i]);
      cout << res << endl;
    }
  }
}
