#include <bits/stdc++.h>
using namespace std;
void Freopen() {
  freopen(
      "title"
      ".in",
      "r", stdin);
  freopen(
      "title"
      ".out",
      "w", stdout);
}
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int INF = 1e9 + 1;
const int N = 1e5 + 5;
struct Seg {
  int mx[2][N << 2], cx[2][N << 2], tag[2][N << 2], flag[N << 2],
      cnt[2][N << 2];
  long long su[N << 2];
  void build(int v, int l, int r) {
    for (int opt = (0); opt <= (1); opt++)
      mx[opt][v] = INF, cx[opt][v] = -INF, tag[opt][v] = INF;
    if (l == r) return void();
    int mid = l + r >> 1;
    build(v << 1, l, mid), build(v << 1 | 1, mid + 1, r);
  }
  void up(int v) {
    flag[v] = flag[v << 1] & flag[v << 1 | 1];
    su[v] = su[v << 1] + su[v << 1 | 1];
    for (int opt = (0); opt <= (1); opt++) {
      mx[opt][v] = max(mx[opt][v << 1], mx[opt][v << 1 | 1]);
      cx[opt][v] = max(cx[opt][v << 1], cx[opt][v << 1 | 1]);
      if (mx[opt][v << 1] < mx[opt][v << 1 | 1])
        cx[opt][v] = max(cx[opt][v], mx[opt][v << 1]);
      if (mx[opt][v << 1] > mx[opt][v << 1 | 1])
        cx[opt][v] = max(cx[opt][v], mx[opt][v << 1 | 1]);
      cnt[opt][v] = cnt[opt][v << 1] * (mx[opt][v] == mx[opt][v << 1]) +
                    cnt[opt][v << 1 | 1] * (mx[opt][v] == mx[opt][v << 1 | 1]);
    }
  }
  void down(int v, int l, int r) {
    int mid = l + r >> 1;
    for (int opt = (0); opt <= (1); opt++)
      if (tag[opt][v] ^ INF) {
        change(opt, v << 1, l, mid, l, mid, tag[opt][v]),
            change(opt, v << 1 | 1, mid + 1, r, mid + 1, r, tag[opt][v]);
        tag[opt][v] = INF;
      }
  }
  void change(int opt, int v, int l, int r, int ql, int qr, int w) {
    if (l == r) {
      flag[v] |= (1 << opt);
      mx[opt][v] = min(mx[opt][v], w);
      if (flag[v] == 3) cnt[0][v] = cnt[1][v] = 1, su[v] = mx[0][v] + mx[1][v];
      return void();
    }
    if (ql <= l && r <= qr && (flag[v] & (1 << opt))) {
      if (w >= mx[opt][v]) return void();
      if (w > cx[opt][v]) {
        su[v] -= 1ll * cnt[opt][v] * (mx[opt][v] - w);
        mx[opt][v] = w, tag[opt][v] = min(tag[opt][v], w);
        return void();
      }
    }
    int mid = l + r >> 1;
    down(v, l, r);
    if (ql <= mid) change(opt, v << 1, l, mid, ql, qr, w);
    if (qr > mid) change(opt, v << 1 | 1, mid + 1, r, ql, qr, w);
    up(v);
  }
  long long query(int v, int l, int r, int ql, int qr) {
    if (ql <= l && r <= qr) return su[v];
    int mid = l + r >> 1;
    down(v, l, r);
    if (qr <= mid) return query(v << 1, l, mid, ql, qr);
    if (ql > mid) return query(v << 1 | 1, mid + 1, r, ql, qr);
    return query(v << 1, l, mid, ql, qr) +
           query(v << 1 | 1, mid + 1, r, ql, qr);
  }
} seg;
signed main() {
  int n = 1e5;
  seg.build(1, 1, n);
  for (int T = read(); T--;) {
    int opt = read(), l = read(), r = read() - 1, x;
    if (opt == 1)
      x = read(), seg.change(x > 0, 1, 1, n, l, r, abs(x));
    else
      cout << seg.query(1, 1, n, l, r) << '\n';
  }
  return signed();
}
