#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
const int INF = 1e9 + 7;
int arr1[N], arr2[N];
int main() {
  for (int i = 0; i < N; i++) {
    arr1[i] = arr2[i] = INF;
  }
  int q;
  cin >> q;
  while (q--) {
    int t, l, r;
    cin >> t >> l >> r;
    l--;
    r--;
    if (t == 1) {
      int k;
      scanf("%d", &k);
      if (k > 0) {
        for (int i = l; i < r; i++) {
          arr1[i] = min(arr1[i], k);
        }
      } else {
        k = -k;
        for (int i = l; i < r; i++) {
          arr2[i] = min(arr2[i], k);
        }
      }
    } else {
      long long ans = 0;
      for (int i = l; i < r; i++) {
        if (arr1[i] < INF && arr2[i] < INF) {
          ans += arr1[i] + arr2[i];
        }
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}
