#include <bits/stdc++.h>
using namespace std;
int const K = 333;
int const N = 100100;
int const INF = 1 << 30;
int type[N], jahdskjhsdj[N], lkjljzxlcjlk[N], blockMax[N], blockMin[N], xs[N],
    mx[N], mn[N], value[N];
int main() {
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", type + i, jahdskjhsdj + i, lkjljzxlcjlk + i);
    if (type[i] == 1) {
      scanf("%d", value + i);
    }
  }
  for (int i = 0; i < N; i++) {
    mx[i] = INF;
    mn[i] = -INF;
  }
  for (int from = 0; from < q; from += K) {
    int to = std::min(q, from + K);
    int cn = 0;
    xs[cn++] = N;
    for (int i = 0; i < to; i++) {
      xs[cn++] = jahdskjhsdj[i];
      xs[cn++] = lkjljzxlcjlk[i];
    }
    std::sort(xs, xs + cn);
    cn = (int)(std::unique(xs, xs + cn) - xs);
    std::fill(blockMax, blockMax + cn, INF);
    std::fill(blockMin, blockMin + cn, -INF);
    for (int i = 0, j = 0; i < N; i++) {
      if (xs[j] == i) {
        ++j;
      }
      blockMax[j] = std::min(blockMax[j], mx[i]);
      blockMin[j] = std::max(blockMin[j], mn[i]);
    }
    for (int i = from; i < to; i++) {
      int lb = (int)(std::lower_bound(xs, xs + cn, jahdskjhsdj[i]) - xs) + 1;
      int rb = (int)(std::lower_bound(xs, xs + cn, lkjljzxlcjlk[i]) - xs) + 1;
      if (type[i] == 1) {
        int k = value[i];
        if (k > 0) {
          for (int j = lb; j < rb; j++) {
            blockMax[j] = std::min(blockMax[j], k);
          }
        } else {
          for (int j = lb; j < rb; j++) {
            blockMin[j] = std::max(blockMin[j], k);
          }
        }
      } else {
        long long ans = 0;
        for (int j = lb; j < rb; j++) {
          if (blockMax[j] != INF && blockMin[j] != -INF) {
            ans += (long long)(blockMax[j] - blockMin[j]) * (xs[j] - xs[j - 1]);
          }
        }
        printf("%lld\n", ans);
      }
    }
    for (int i = 0, j = 0; i < N; i++) {
      if (xs[j] == i) ++j;
      mx[i] = std::min(mx[i], blockMax[j]);
      mn[i] = std::max(mn[i], blockMin[j]);
    }
  }
}
