#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 1;
struct node {
  int mx1, mx2, cntmx1;
  long long sum;
  node() { mx1 = inf, mx2 = -1, cntmx1 = 1, sum = inf; }
  friend node combine(const node &l, const node &r) {
    node res;
    res.mx1 = max(l.mx1, r.mx1);
    if (l.mx1 > r.mx1)
      res.mx2 = max(l.mx2, r.mx1);
    else if (l.mx1 < r.mx1)
      res.mx2 = max(l.mx1, r.mx2);
    else
      res.mx2 = max(l.mx2, r.mx2);
    res.cntmx1 = (l.mx1 == res.mx1 ? l.cntmx1 : 0);
    res.cntmx1 += (r.mx1 == res.mx1 ? r.cntmx1 : 0);
    assert(res.cntmx1 > 0);
    res.sum = l.sum + r.sum;
    return res;
  }
};
struct segtree {
  vector<node> val;
  int tsz;
  void upd(int v) { val[v] = combine(val[2 * v], val[2 * v + 1]); }
  vector<int> br_arr;
  segtree(int n) {
    tsz = 1;
    while (tsz < n) tsz *= 2;
    val.assign(2 * tsz, node());
    for (int i = ((int)(tsz)-1); i >= 0; --i)
      if (i) upd(i);
    br_arr.assign(n, inf);
  }
  void push(int v) {
    for (int son = 2 * v; son <= 2 * v + 1; son++)
      if (val[v].mx1 < val[son].mx1) {
        val[son].sum -=
            (long long)(val[son].mx1 - val[v].mx1) * val[son].cntmx1;
        val[son].mx1 = val[v].mx1;
      }
  }
  void update(int v, int l, int r, int L, int R, int what) {
    if (l >= R || r <= L) return;
    if (val[v].mx1 <= what) return;
    if (l <= L && R <= r && val[v].mx2 < what) {
      assert(what < val[v].mx1);
      val[v].sum -= (long long)(val[v].mx1 - what) * val[v].cntmx1;
      val[v].mx1 = what;
      return;
    }
    push(v);
    int M = (L + R) / 2;
    update(2 * v, l, r, L, M, what);
    update(2 * v + 1, l, r, M, R, what);
    upd(v);
  }
  long long gosum(int v, int l, int r, int L, int R) {
    if (l >= R || r <= L) return 0;
    if (l <= L && R <= r) return val[v].sum;
    push(v);
    int M = (L + R) / 2;
    return gosum(2 * v, l, r, L, M) + gosum(2 * v + 1, l, r, M, R);
  }
  long long brut_sum(int l, int r) {
    long long ans = 0;
    for (int i = l; i < r; i++) ans += br_arr[i];
    return ans;
  }
  void brut_remin(int l, int r, int x) {
    for (int i = l; i < r; i++) br_arr[i] = min(br_arr[i], x);
  }
  long long getsum(int l, int r) {
    long long ans = gosum(1, l, r, 0, tsz);
    return ans;
  }
  void remin_seg(int l, int r, int what) { update(1, l, r, 0, tsz, what); }
};
void solve(int q) {
  const int n = (int)1e5;
  vector<segtree> data(4, segtree(n));
  vector<set<int>> notalive(2);
  for (int i = 0; i < (int)(2); ++i)
    for (int j = 0; j < (int)(n); ++j) notalive[i].insert(j);
  auto transfer = [&](int side, int l, int r, int what) {
    while (true) {
      auto it = notalive[side].lower_bound(l);
      if (it == notalive[side].end() || *it >= r) break;
      const int cur = *it;
      if (!notalive[side ^ 1].count(cur)) {
        data[2].remin_seg(cur, cur + 1, 0);
        data[3].remin_seg(cur, cur + 1, 0);
        long long curans = 0;
        for (int i = 0; i < (int)(4); ++i) {
          long long addcur = data[i].getsum(cur, cur + 1);
          curans += (i < 2 ? addcur : -addcur);
        }
      }
      notalive[side].erase(it);
    }
    data[side + 2].remin_seg(l, r, what);
  };
  for (int it = 0; it < (int)(q); ++it) {
    int t, l, r;
    cin >> t >> l >> r;
    if (t == 1) {
      int y;
      cin >> y;
      int side = (y < 0 ? 1 : 0);
      int ry = abs(y);
      data[side].remin_seg(l, r, ry);
      transfer(side, l, r, ry);
    } else {
      assert(t == 2);
      long long ans = 0;
      for (int i = 0; i < (int)(4); ++i) {
        long long cur = data[i].getsum(l, r);
        ans += (i < 2 ? cur : -cur);
      }
      cout << ans << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  while (cin >> n) solve(n);
}
