#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool Max(T1& a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T1, typename T2>
bool Min(T1& a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
const int N = 100001;
const int inf = 1e9 + 1;
struct SQRT {
  typedef int T[2];
  static constexpr long long defaultRES = 0;
  static long long combine(long long a, long long b) { return a + b; }
  struct BLK {
    int n;
    T* a;
    int mx[2], mxcnt[2];
    vector<int> vec[2];
    long long ans;
    void init(int n_, T* a_) {
      n = n_;
      a = a_;
      for (int i = 0; i < (n); ++i) {
        for (int c = 0; c < (2); ++c) a[i][c] = inf;
      }
      for (int c = 0; c < (2); ++c) mx[c] = inf;
      ans = 0;
    }
    void push() {
      for (int i = 0; i < (n); ++i) {
        auto& x = a[i];
        for (int c = 0; c < (2); ++c) Min(x[c], mx[c]);
      }
    }
    void pull() {
      for (int c = 0; c < (2); ++c) vec[c].clear(), mxcnt[c] = 0, mx[c] = 0;
      ans = 0;
      for (int i = 0; i < (n); ++i) {
        auto& x = a[i];
        for (int c = 0; c < (2); ++c) {
          Max(mx[c], x[c]);
        }
      }
      for (int i = 0; i < (n); ++i) {
        auto& x = a[i];
        if (x[0] < inf && x[1] < inf) {
          ans += x[0] + x[1];
          for (int c = 0; c < (2); ++c) {
            if (x[c] < mx[c])
              vec[c].push_back(x[c]);
            else
              mxcnt[c]++;
          }
        }
      }
      for (int c = 0; c < (2); ++c) sort(vec[c].begin(), vec[c].end());
    }
    void update(T& x, const T& ad) {
      for (int c = 0; c < (2); ++c) Min(x[c], ad[c]);
    }
    void update(const T& ad) {
      for (int c = 0; c < (2); ++c) {
        if (ad[c] >= mx[c]) continue;
        int old = mx[c];
        mx[c] = ad[c];
        if (old == inf) {
          push();
          pull();
          return;
        }
        int remcnt = 0;
        while (vec[c].size() && vec[c].back() >= ad[c]) {
          ans -= vec[c].back();
          remcnt++;
          vec[c].pop_back();
        }
        ans -= (long long)old * mxcnt[c];
        mxcnt[c] += remcnt;
        ans += (long long)mxcnt[c] * mx[c];
      }
    }
    long long query(T& x) {
      if (x[0] < inf && x[1] < inf) return x[0] + x[1];
      return 0;
    }
    long long query() { return ans; }
  };
  int B;
  T* a;
  unique_ptr<T[]> _a;
  unique_ptr<BLK[]> blk;
  void init(int n, T* a_ = 0) {
    B = sqrt(n);
    int NB = (n + B - 1) / B;
    if (a_)
      a = a_;
    else {
      _a.reset(new T[n]);
      a = _a.get();
    }
    blk.reset(new BLK[NB]);
    for (int i = 0; i < (NB); ++i)
      blk[i].init(min(B, n - i * B + 1), &a[i * B]);
  }
  void update(int l, int r, const T& ad) {
    int bl = l / B, br = r / B;
    l %= B, r %= B;
    auto& b1 = blk[bl];
    if (bl == br) {
      b1.push();
      for (int i = l; i <= (r); ++i) b1.update(b1.a[i], ad);
      b1.pull();
    } else {
      b1.push();
      for (int i = l; i <= (B - 1); ++i) b1.update(b1.a[i], ad);
      b1.pull();
      for (int b = bl + 1; b <= (br - 1); ++b) blk[b].update(ad);
      auto& b2 = blk[br];
      b2.push();
      for (int i = 0; i <= (r); ++i) b2.update(b2.a[i], ad);
      b2.pull();
    }
  }
  long long query(int l, int r) {
    int bl = l / B, br = r / B;
    l %= B, r %= B;
    long long ans = defaultRES;
    auto& b1 = blk[bl];
    if (bl == br) {
      b1.push();
      for (int i = l; i <= (r); ++i) ans = combine(ans, b1.query(b1.a[i]));
    } else {
      b1.push();
      for (int i = l; i <= (B - 1); ++i) ans = combine(ans, b1.query(b1.a[i]));
      for (int b = bl + 1; b <= (br - 1); ++b)
        ans = combine(ans, blk[b].query());
      auto& b2 = blk[br];
      b2.push();
      for (int i = 0; i <= (r); ++i) ans = combine(ans, b2.query(b2.a[i]));
    }
    return ans;
  }
};
void solve() {
  int q, op, l, r, k;
  cin >> q;
  SQRT st;
  st.init(N);
  while (q--) {
    cin >> op >> l >> r;
    r--;
    if (op == 1) {
      int ad[2] = {inf, inf};
      cin >> k;
      if (k > 0)
        ad[0] = k;
      else
        ad[1] = -k;
      st.update(l, r, ad);
    } else {
      long long ans = st.query(l, r);
      cout << ans << '\n';
    }
  }
}
void init() {}
void gen() {}
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  if (argc > 1 && strcmp(argv[1], "gen") == 0) {
    gen();
    return 0;
  }
  init();
  int TC = 1;
  for (int TI = 1; TI <= (TC); ++TI) {
    solve();
  }
  return 0;
}
