#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops, no-stack-protector")
#pragma GCC target("avx,avx2,fma,sse,sse2,sse3,sse4")
using namespace std;
void FAST_IO(string filein = "", string fileout = "", string fileerr = "") {
  if (fopen(filein.c_str(), "r")) {
    freopen(filein.c_str(), "r", stdin);
    freopen(fileout.c_str(), "w", stdout);
  }
  cin.tie(0), cout.tie(0)->sync_with_stdio(0);
}
void Hollwo_Pelw();
signed main() {
  FAST_IO("hollwo_pelw.inp", "hollwo_pelw.out");
  int testcases = 1;
  for (int test = 1; test <= testcases; test++) {
    Hollwo_Pelw();
  }
  return 0;
}
const int N = 1e5 + 5, SZ = 300, BLK = 400;
int a[2][N], lz[2][BLK];
bool safe[2][BLK];
int sz[2][BLK];
vector<int> v[2][BLK];
long long tot[BLK];
inline void upd(int &v, int b) { v = !v ? b : min(v, b); }
inline void add(long long &v, int id) {
  v += a[0][id] && a[1][id] ? a[0][id] + a[1][id] : 0;
}
inline int tl(int id) { return id * SZ; }
inline int tr(int id) { return (id + 1) * SZ - 1; }
inline void __break__(int id) {
  for (int tp = 0; tp < 2; tp++) {
    if (!lz[tp][id]) continue;
    for (int i = tl(id); i <= tr(id); i++) upd(a[tp][i], lz[tp][id]);
    lz[tp][id] = 0;
  }
}
inline void __build__(int id) {
  for (int tp = 0; tp < 2; tp++) {
    safe[tp][id] = 0;
    for (int i = tl(id); i <= tr(id); i++)
      if (!a[tp][0]) {
        safe[tp][id] = 1;
        break;
      }
    if (safe[tp][id]) continue;
    v[tp][id].clear();
    for (int i = tl(id); i <= tr(id); i++) v[tp][id].push_back(a[tp][i]);
    sz[tp][id] = v[tp][id].size();
    sort(v[tp][id].begin(), v[tp][id].end());
  }
  tot[id] = 0;
  for (int i = tl(id); i <= tr(id); i++) add(tot[id], i);
}
void __upd_full__(int tp, int id, int val) {
  int lst = lz[tp][id];
  upd(lz[tp][id], val);
  if (safe[tp][id]) return __break__(id), __build__(id);
  if (lst > val) {
    tot[id] -= 1ll * (lst - val) * (sz[tp][id] - (int)v[tp][id].size());
    while (!v[tp][id].empty() && v[tp][id].back() > val)
      tot[id] -= v[tp][id].back() - val, v[tp][id].pop_back();
  }
}
void __upd_range__(int tp, int l, int r, int val) {
  int lb = l / SZ, rb = r / SZ;
  if (lb == rb) {
    __break__(lb);
    for (int i = l; i <= r; i++) upd(a[tp][i], val);
    return __build__(lb);
  }
  __break__(lb);
  for (int i = l; i <= tr(lb); i++) upd(a[tp][i], val);
  __build__(lb);
  __break__(rb);
  for (int i = tl(rb); i <= r; i++) upd(a[tp][i], val);
  __build__(rb);
  for (int id = lb + 1; id < rb; id++) __upd_full__(tp, id, val);
}
void __query_range__(int l, int r) {
  long long res = 0;
  int lb = l / SZ, rb = r / SZ;
  if (lb == rb) {
    __break__(lb);
    for (int i = l; i <= r; i++) add(res, i);
    cout << res << '\n';
    return __build__(rb);
  }
  __break__(lb);
  for (int i = l; i <= tr(lb); i++) add(res, i);
  __build__(lb);
  __break__(rb);
  for (int i = tl(rb); i <= r; i++) add(res, i);
  __build__(rb);
  for (int id = lb + 1; id < rb; id++) res += tot[id];
  cout << res << '\n';
}
const int n = 100000;
void Hollwo_Pelw() {
  for (int i = 0; i < BLK; i++) __build__(i);
  int q;
  cin >> q;
  for (int _ = 0, t, l, r, x, ok = 0; _ < q; _++) {
    cin >> t >> l >> r, --r;
    if (t == 1) {
      ok = 1;
      cin >> x;
      if (x < 0) x = -x, t ^= 1;
      __upd_range__(t ^ 1, l, r, x);
    } else {
      __query_range__(l, r);
    }
  }
}
