#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int q;
  cin >> q;
  int minn[2][100005], inf = 1000000007;
  for (int i = 1; i <= 100000; i++) minn[0][i] = minn[1][i] = inf;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, k;
      cin >> l >> r >> k;
      bool s = (k > 0);
      k = abs(k);
      for (int i = l; i < r; i++) minn[s][i] = min(minn[s][i], k);
    } else {
      int l, r;
      cin >> l >> r;
      long long int tot = 0;
      for (int i = l; i < r; i++)
        if (minn[0][i] != inf && minn[1][i] != inf)
          tot += minn[0][i] + minn[1][i];
      cout << tot << '\n';
    }
  }
}
