#include <stdio.h>

int nums1[270000], nums2[270000];
int leaves;

void help(int i, int left, int right) {
  if (!nums2[i])
    return;
  
  nums1[i] += nums2[i] * (right - left);

  if (right - left > 1) {
    nums2[i * 2] += nums2[i];
    nums2[i * 2 + 1] += nums2[i];
  }

  nums2[i] = 0;
}

void add(int nl, int nr, int val, int node, int l, int r) {
  help(node, l, r);

  if (r <= nl || nr <= l)
    return;
  else if (nl <= l && r <= nr) {
    nums2[node] += val;
    help(node, l, r);
  } else {
    add(nl, nr, val, node * 2, l, (l + r) / 2);
    add(nl, nr, val, node * 2 + 1, (l + r) / 2, r);
    nums1[node] = nums1[node * 2] + nums1[node * 2 + 1];
  }
}

int get(int nl, int nr, int node, int l, int r) {
  help(node, l, r);

  if (nr <= l || r <= nl)
    return 0;
  else if (nl <= l && r <= nr)
    return nums1[node];
  
  return get(nl, nr, node * 2, l, (l + r) / 2) + get(nl, nr, node * 2 + 1, (l + r) / 2, r);
}

int main() {
  int n, q, i, x, y, z, command;
  int indexes[100005] = {};
  
  scanf("%d %d", &n, &q);
  
  for (leaves = 1; leaves < n; leaves *= 2);

  for (i = 0; i < leaves; i++) {
    if (i < n)
      nums1[leaves + i] = indexes[i];
    else
      nums1[leaves + i] = 0;
  }
  
  for (i = leaves - 1; i; i--)
    nums1[i] = nums1[i * 2] + nums1[i * 2 + 1];
  
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &command, &x, &y);

    if (command)
      printf("%d\n", get(x - 1, y, 1, 0, leaves));
    else {
      scanf("%d", &z);
      add(x - 1, y, z, 1, 0, leaves);
    }	     
  }
}

