void UpDate(Node *p, int x, int y, int L, int R, w)
{
  if (y < L || R < x) return;
  if (x <= L && R <= y)
  {
     p -> Delta += w;
     return;
  }
  if (p -> Left == null) p -> Left = new Node(0, 0, NULL, NULL);
  if (p -> Right == null) p -> Right = new Node(0, 0, NULL, NULL);
  p -> Left -> Delta += p -> Delta;
  p -> Right -> Delta += p -> Delta;
  p -> Delta = 0;
  int m = (x + y) >> 1;
  UpDate(p -> Left, x, m, L, R, w);
  UpDate(p -> Right, m + 1, y, L, R, w);
  p -> Sum = p -> Left -> Sum + (m - x + 1)*p -> Left -> Delta + p -> Right -> Sum + (y - m )*p -> Right -> Delta;  
}