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