How to collect difference in elevation between tubes horizontally within the same list but in different indices

Good morning,
I need your help I have a list as shown in the image of the black rectangle with several tubes in the horizontal position but with different elevations, as shown by the parameters “Start intermediate elevation” and “End intermediate elevation” the problem and that this list is unique as If there is a rectangle. My problem is how to collect the item elevation at index [0] = 1,183 and the sequential item in case [1] = 0.0999 … and result in the difference in elevation between them in case [0] - [1] = 1.08, [1] - [2] = 0.00, [2] - [n] … and continue doing the same process until the end of the list.

@Tiago …Could you share the dyn and revit file…then its easier to see whats goin on here :wink: