#include <bits/stdc++.h>
using namespace std;
int q, t, l, r, k, a[100005][2];
long long ans;
int main() {
  for (scanf("%d", &q); q--;) {
    scanf("%d%d%d", &t, &l, &r);
    if (t & 1)
      for (scanf("%d", &k); l < r; l++)
        a[l][k < 0] = a[l][k < 0] ? min(a[l][k < 0], abs(k)) : abs(k);
    else {
      for (ans = 0; l < r; l++)
        ans += a[l][0] && a[l][1] ? a[l][0] + a[l][1] : 0;
      printf("%lld\n", ans);
    }
  }
}
