#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int inf = 1e9 + 10;
int minn[N], minp[N];
int main() {
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= 100000; i++) minp[i] = minn[i] = inf;
  while (q--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int l, r, k;
      scanf("%d", &l);
      scanf("%d", &r);
      scanf("%d", &k);
      if (k < 0)
        for (int i = l; i < r; i++)
          minn[i] = (minn[i]) < (-k) ? (minn[i]) : (-k);
      else
        for (int i = l; i < r; i++) minp[i] = (minp[i]) < (k) ? (minp[i]) : (k);
    } else {
      int l, r;
      scanf("%d", &l);
      scanf("%d", &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];
      printf("%lld\n", tot);
    }
  }
}
