#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
struct SegmentTreeBeats {
  struct node {
    int mx, smx, nmx, laz;
    long long sum;
    bool allIN;
  };
  node tree[N << 2];
  void build(int node, int s, int e) {
    tree[node].laz = INT_MAX;
    if (s == e) {
      tree[node].mx = INT_MAX;
      tree[node].smx = INT_MIN;
      tree[node].nmx = e - s + 1;
      tree[node].sum = 0;
      tree[node].allIN = false;
    } else {
      int md = (s + e) >> 1;
      build(node << 1, s, md);
      build(node << 1 | 1, md + 1, e);
      pull(node);
    }
  }
  void push(int node, int s, int e) {
    if (tree[node].laz == INT_MAX || s == e) return;
    int md = (s + e) >> 1;
    assignVal(tree[node << 1], tree[node].laz);
    assignVal(tree[node << 1 | 1], tree[node].laz);
    tree[node].laz = INT_MAX;
  }
  void pull(int node) {
    tree[node].allIN = tree[node << 1].allIN & tree[node << 1 | 1].allIN;
    tree[node].sum = tree[node << 1].sum + tree[node << 1 | 1].sum;
    vector<int> vp = {INT_MIN, tree[node << 1].mx, tree[node << 1].smx,
                      tree[node << 1 | 1].mx, tree[node << 1 | 1].smx};
    sort(vp.begin(), vp.end());
    vp.resize(unique(vp.begin(), vp.end()) - vp.begin());
    tree[node].mx = vp.back();
    tree[node].smx = vp[vp.size() - 2];
    tree[node].nmx =
        (tree[node].mx == tree[node << 1].mx) * tree[node << 1].nmx +
        (tree[node].mx == tree[node << 1 | 1].mx) * tree[node << 1 | 1].nmx;
  }
  void assignVal(node& x, int v) {
    if (x.allIN) x.sum -= x.mx * 1ll * x.nmx;
    x.laz = min(x.laz, v);
    x.mx = min(x.mx, x.laz);
    x.sum += x.mx * 1ll * x.nmx;
    x.allIN = 1;
  }
  void upd(int node, int s, int e, int l, int r, int v) {
    push(node, s, e);
    if (r < s || e < l || tree[node].mx <= v) return;
    if (l <= s && e <= r && tree[node].smx < v) {
      assignVal(tree[node], v);
    } else {
      int md = (s + e) >> 1;
      upd(node << 1, s, md, l, r, v);
      upd(node << 1 | 1, md + 1, e, l, r, v);
      pull(node);
    }
  }
} up, down;
long long qry(int node, int s, int e, int l, int r) {
  up.push(node, s, e);
  down.push(node, s, e);
  if (r < s || e < l || !up.tree[node].sum || !down.tree[node].sum) return 0;
  if (l <= s && e <= r && up.tree[node].allIN && down.tree[node].allIN)
    return up.tree[node].sum + down.tree[node].sum;
  int md = (s + e) >> 1;
  return qry(node << 1, s, md, l, r) + qry(node << 1 | 1, md + 1, e, l, r);
}
int main() {
  int q;
  scanf("%d", &q);
  up.build(1, 0, 100000);
  down.build(1, 0, 100000);
  while (q--) {
    int tp;
    scanf("%d", &tp);
    if (tp == 1) {
      int l, r, v;
      scanf("%d%d%d", &l, &r, &v);
      --r;
      if (v > 0)
        up.upd(1, 0, 100000, l, r, v);
      else
        down.upd(1, 0, 100000, l, r, -v);
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      --r;
      printf("%lld\n", qry(1, 0, 100000, l, r));
    }
  }
  return 0;
}
