#include <bits/stdc++.h>
namespace IO {
const unsigned int Buffsize = 1 << 15, Output = 1 << 23;
static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
static char Out[Output], *nowps = Out;
inline void flush() {
  fwrite(Out, 1, nowps - Out, stdout);
  nowps = Out;
}
template <class T>
inline void read(T &_) {
  _ = 0;
  static char __;
  T ___ = 1;
  for (__ = ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin),
                           S_ == T_)
                 ? 0
                 : *S_++);
       !isdigit(__);
       __ = ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin),
                           S_ == T_)
                 ? 0
                 : *S_++))
    if (__ == '-') ___ = -1;
  for (; isdigit(__);
       __ = ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin),
                           S_ == T_)
                 ? 0
                 : *S_++))
    _ = (_ << 3) + (_ << 1) + (__ ^ 48);
  _ *= ___;
}
template <class T>
inline void write(T _, char __ = '\n') {
  if (!_) *nowps++ = ('0');
  if (_ < 0) *nowps++ = ('-'), _ = -_;
  static unsigned int sta[111], tp;
  for (tp = 0; _; _ /= 10) sta[++tp] = _ % 10;
  for (; tp; *nowps++ = (sta[tp--] ^ 48))
    ;
  *nowps++ = (__);
}
template <class T>
inline bool chkmax(T &_, T __) {
  return _ < __ ? _ = __, 1 : 0;
}
template <class T>
inline bool chkmin(T &_, T __) {
  return _ > __ ? _ = __, 1 : 0;
}
}  // namespace IO
using namespace std;
using namespace IO;
const int N = 1e5 + 10;
const int n = 1e5;
struct Segment_Tree {
  long long sum[N << 2];
  bool allin[N << 2];
  int nmx[N << 2], mx[N << 2], smx[N << 2], tag[N << 2];
  void modify(int bh, int val) {
    sum[bh] -= (long long)allin[bh] * mx[bh] * nmx[bh];
    chkmin(tag[bh], val), chkmin(mx[bh], val);
    sum[bh] += (long long)mx[bh] * nmx[bh] * (allin[bh] = 1);
  }
  void pushup(int bh) {
    allin[bh] = allin[(bh << 1)] & allin[((bh << 1) | 1)],
    sum[bh] = sum[(bh << 1)] + sum[((bh << 1) | 1)];
    vector<int> vp = {-(0x3f3f3f3f), mx[(bh << 1)], smx[(bh << 1)],
                      mx[((bh << 1) | 1)], smx[((bh << 1) | 1)]};
    sort(vp.begin(), vp.end());
    vp.erase(unique(vp.begin(), vp.end()), vp.end());
    mx[bh] = vp.back(), smx[bh] = vp[vp.size() - 2];
    nmx[bh] = (mx[bh] == mx[(bh << 1)]) * nmx[(bh << 1)] +
              (mx[bh] == mx[((bh << 1) | 1)]) * nmx[((bh << 1) | 1)];
  }
  void pushdown(int bh) {
    if (tag[bh] ^ (0x3f3f3f3f))
      modify((bh << 1), tag[bh]), modify(((bh << 1) | 1), tag[bh]),
          tag[bh] = (0x3f3f3f3f);
  }
  void build(int bh, int l, int r) {
    tag[bh] = mx[bh] = (0x3f3f3f3f), smx[bh] = -(0x3f3f3f3f);
    nmx[bh] = r - l + 1, sum[bh] = allin[bh] = 0;
    if (l ^ r)
      build((bh << 1), l, ((l + r) >> 1)),
          build(((bh << 1) | 1), ((l + r) >> 1) + 1, r);
  }
  void update(int bh, int l, int r, int first, int second, int z) {
    if (second < l || first > r || mx[bh] <= z) return;
    if (first <= l && r <= second && smx[bh] <= z)
      modify(bh, z);
    else {
      pushdown(bh);
      update((bh << 1), l, ((l + r) >> 1), first, second, z);
      update(((bh << 1) | 1), ((l + r) >> 1) + 1, r, first, second, z);
      pushup(bh);
    }
  }
} T[2];
long long query(int bh, int l, int r, int first, int second) {
  if (second < l || first > r || !T[0].sum[bh] || !T[1].sum[bh]) return 0;
  if (first <= l && r <= second && T[0].allin[bh] && T[1].allin[bh])
    return T[0].sum[bh] + T[1].sum[bh];
  T[0].pushdown(bh), T[1].pushdown(bh);
  return query((bh << 1), l, ((l + r) >> 1), first, second) +
         query(((bh << 1) | 1), ((l + r) >> 1) + 1, r, first, second);
}
int main() {
  int q, opt, first, second, z;
  T[0].build(1, 1, n), T[1].build(1, 1, n);
  for (read(q); q--;) {
    read(opt), read(first), read(second);
    --second;
    if (opt == 1)
      read(z), T[z > 0].update(1, 1, n, first, second, abs(z));
    else
      write(query(1, 1, n, first, second));
  }
  return flush(), 0;
}
