\(u \in [X,LCA] : val[u] \cdot {(dep[u]+dep[Y]-2dep[LCA])(dep[u]+dep[Y]-2dep[LCA]+1) \over 2}\)
\(=val[u]\cdot{[dep[Y](dep[y]+1)-2dep[LCA](2dep[Y] -2dep[LCA]+1)]+dep[i](1+2dep[y]-4dep[LCA])+dep^2[i] \over 2}\)
\(u \in [LCA,Y] : {val[u] \cdot (dep[Y]-dep[i])(dep[Y]-dep[i]+1) \over 2}\)
\(= val[u] \cdot {dep[Y](dep[Y]+1)-dep[i](1+2dep[Y]) + dep^2[i]\over 2}\)