#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int INF = 1 << 30;
const int N = 100000;
int node[2][maxn << 2], se[2][maxn << 2], lazy[2][maxn << 2], cnt[2][maxn << 2];
long long sum[2][maxn << 2];
bool modify(int rt, int c, int k) {
  if (c <= se[k][rt]) return false;
  if (c < node[k][rt]) {
    sum[k][rt] -= (long long)(node[k][rt] - c) * cnt[k][rt];
    node[k][rt] = c;
    lazy[k][rt] = c;
  }
  return true;
}
void pushup(int rt) {
  for (int k = 0; k < 2; ++k) {
    node[k][rt] = max(node[k][rt << 1], node[k][rt << 1 | 1]);
    sum[k][rt] = sum[k][rt << 1] + sum[k][rt << 1 | 1];
    if (node[k][rt << 1] == node[k][rt << 1 | 1]) {
      se[k][rt] = max(se[k][rt << 1], se[k][rt << 1 | 1]);
      cnt[k][rt] = cnt[k][rt << 1] + cnt[k][rt << 1 | 1];
    } else if (node[k][rt << 1] < node[k][rt << 1 | 1]) {
      se[k][rt] = max(node[k][rt << 1], se[k][rt << 1 | 1]);
      cnt[k][rt] = cnt[k][rt << 1 | 1];
    } else {
      se[k][rt] = max(se[k][rt << 1], node[k][rt << 1 | 1]);
      cnt[k][rt] = cnt[k][rt << 1];
    }
  }
}
void pushdown(int rt) {
  for (int k = 0; k < 2; ++k) {
    if (lazy[k][rt] != INF) {
      modify(rt << 1, lazy[k][rt], k);
      modify(rt << 1 | 1, lazy[k][rt], k);
      lazy[k][rt] = INF;
    }
  }
}
void build(int rt, int l, int r) {
  for (int i = 0; i < 2; ++i) {
    sum[i][rt] = 0;
    cnt[i][rt] = 0;
    se[i][rt] = node[i][rt] = lazy[i][rt] = INF;
  }
  if (r - l == 1) return;
  int m = (l + r) >> 1;
  build(rt << 1, l, m);
  build(rt << 1 | 1, m, r);
}
void update(int rt, int l, int r, int x, int y, int c, int k) {
  if (c >= node[k][rt]) return;
  if (r - l == 1) {
    node[k][rt] = c;
    se[k][rt] = -INF;
    if (node[k ^ 1][rt] != INF) {
      sum[k][rt] = c;
      cnt[k][rt] = 1;
      sum[k ^ 1][rt] = node[k ^ 1][rt];
      cnt[k ^ 1][rt] = 1;
    }
    return;
  }
  if (x <= l && r <= y && modify(rt, c, k)) return;
  pushdown(rt);
  int m = (l + r) >> 1;
  if (x < m) update(rt << 1, l, m, x, y, c, k);
  if (m < y) update(rt << 1 | 1, m, r, x, y, c, k);
  pushup(rt);
}
long long query(int rt, int l, int r, int x, int y) {
  if (x <= l && r <= y) return sum[0][rt] + sum[1][rt];
  pushdown(rt);
  int m = (l + r) >> 1;
  long long ret = 0;
  if (x < m) ret += query(rt << 1, l, m, x, y);
  if (m < y) ret += query(rt << 1 | 1, m, r, x, y);
  return ret;
}
int main() {
  build(1, 1, N);
  int q;
  scanf("%d", &q);
  while (q--) {
    int t, l, r, c;
    scanf("%d%d%d", &t, &l, &r);
    if (t == 1) {
      scanf("%d", &c);
      if (c > 0)
        update(1, 1, N, l, r, c, 0);
      else
        update(1, 1, N, l, r, -c, 1);
    } else
      printf("%I64d\n", query(1, 1, N, l, r));
  }
  return 0;
}
