#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 10;
int minn[N], minp[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int q;
  cin >> q;
  for (int i = 1; i <= 100000; i++) minp[i] = minn[i] = inf;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, k;
      cin >> l >> r >> k;
      if (k < 0)
        for (int i = l; i < r; i++) minn[i] = min(minn[i], -k);
      else
        for (int i = l; i < r; i++) minp[i] = min(minp[i], k);
    } else {
      int l, r;
      cin >> l >> r;
      long long int tot = 0;
      for (int i = l; i < r; i++)
        if (minp[i] < inf && minn[i] < inf) tot += minp[i] + minn[i];
      cout << tot << endl;
    }
  }
}
