#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, q;
bool vis[N][2];
struct seg {
  long long sum[N << 2];
  int cnt[N << 2], mx[N << 2], se[N << 2], tag[N << 2];
  void up(int x) {
    mx[x] = max(mx[(x << 1)], mx[(x << 1 | 1)]);
    se[x] =
        max(mx[x] == mx[(x << 1)] ? se[(x << 1)] : mx[(x << 1)],
            mx[x] == mx[(x << 1 | 1)] ? se[(x << 1 | 1)] : mx[(x << 1 | 1)]);
    cnt[x] = 0;
    if (mx[x] == mx[(x << 1)]) cnt[x] += cnt[(x << 1)];
    if (mx[x] == mx[(x << 1 | 1)]) cnt[x] += cnt[(x << 1 | 1)];
    sum[x] = sum[(x << 1)] + sum[(x << 1 | 1)];
  }
  void mdf(int x, int v) {
    mx[x] += v;
    tag[x] += v;
    sum[x] += 1ll * cnt[x] * v;
  }
  void down(int x) {
    if (tag[x]) {
      if (mx[(x << 1)] + tag[x] == mx[x]) mdf((x << 1), tag[x]);
      if (mx[(x << 1 | 1)] + tag[x] == mx[x]) mdf((x << 1 | 1), tag[x]);
      tag[x] = 0;
    }
  }
  void build(int v, int x = 1, int l = 1, int r = n) {
    if (l == r) {
      mx[x] = sum[x] = v;
      se[x] = -inf;
      cnt[x] = 1;
      return;
    }
    int mid = (l + r) >> 1;
    build(v, (x << 1), l, mid);
    build(v, (x << 1 | 1), mid + 1, r);
    up(x);
  }
  void modify(int p, int v, int x = 1, int l = 1, int r = n) {
    if (l == r) {
      mx[x] = sum[x] = v;
      return;
    }
    down(x);
    int mid = (l + r) >> 1;
    p <= mid ? modify(p, v, (x << 1), l, mid)
             : modify(p, v, (x << 1 | 1), mid + 1, r);
    up(x);
  }
  void modify_min(int L, int R, int v, int x = 1, int l = 1, int r = n) {
    if (mx[x] <= v) return;
    if (L <= l && r <= R && se[x] < v) return mdf(x, v - mx[x]);
    down(x);
    int mid = (l + r) >> 1;
    if (L <= mid) modify_min(L, R, v, (x << 1), l, mid);
    if (R > mid) modify_min(L, R, v, (x << 1 | 1), mid + 1, r);
    up(x);
  }
  long long query(int L, int R, int x = 1, int l = 1, int r = n) {
    if (L <= l && r <= R) return sum[x];
    down(x);
    int mid = (l + r) >> 1;
    long long ret = 0;
    if (L <= mid) ret += query(L, R, (x << 1), l, mid);
    if (R > mid) ret += query(L, R, (x << 1 | 1), mid + 1, r);
    return ret;
  }
} T[2], TT[2];
struct dsu {
  int fa[N];
  void init() {
    for (int i = 1; i <= n; i++) fa[i] = i;
  }
  int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); }
  void cover(int l, int r, int op) {
    for (int i = getf(l); i <= r; i = getf(i + 1)) {
      vis[i][op] = 1;
      if (vis[i][0] && vis[i][1]) {
        T[0].modify(i, TT[0].query(i, i));
        T[1].modify(i, TT[1].query(i, i));
      }
      fa[i] = i + 1;
    }
  }
} D[2];
int main() {
  n = 1e5;
  cin >> q;
  T[0].build(0);
  T[1].build(0);
  TT[0].build(inf);
  TT[1].build(inf);
  D[0].init();
  D[1].init();
  while (q--) {
    int op = gi(), l = gi(), r = gi() - 1;
    if (op == 1) {
      int k = gi(), op = k < 0;
      k = abs(k);
      T[op].modify_min(l, r, k);
      TT[op].modify_min(l, r, k);
      D[op].cover(l, r, op);
    } else
      cout << T[0].query(l, r) + T[1].query(l, r) << '\n';
  }
  return 0;
}
