#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
int a[100005], b[100005], c[100005];
int main() {
  int q;
  cin >> q;
  int type, l, r;
  int k;
  while (q--) {
    scanf("%d%d%d", &type, &l, &r);
    if (type == 1) {
      scanf("%d", &k);
      if (k > 0) {
        for (int i = l; i < r; i++) {
          if (!a[i] || a[i] && a[i] > k) a[i] = k;
          if (b[i]) c[i] = a[i] + b[i];
        }
      } else {
        k = -k;
        for (int i = l; i < r; i++) {
          if (!b[i] || b[i] && b[i] > k) b[i] = k;
          if (a[i]) c[i] = a[i] + b[i];
        }
      }
    } else {
      long long ans = 0;
      for (int i = l; i < r; i++) ans = ans + c[i];
      printf("%lld\n", ans);
    }
  }
  return 0;
}
