I have a list of points which is created with some specific pattern (already modeified, sorted by X value). First of all I want to mention that only X and Z cooridnates are relevant. First and last point would have always Z=0. There would be also few point pairs next to each other like 1 and 2 and 5 and 6 in this case that have also Z=0. All other point would have Z >0. My goal is to find a difference between X coordinates (distance) between pairs of point with Z=0 and adjacent points.
For example:

Point 5 (X=6700)- I need to find a distance to previouse point so point 4 (X=5300). In this case result is 1400.
Point 6 (X=7950)- I need to find distance to next point so point 7 (X=8800). In this case result is 850.

If I understood you correctly, it is guaranteed that the zero-z points will always come in pairs and you want to measure the x difference:
-between first of pair and the previous
-between second of pair and the next
In this case the points I made have a pair at index 0 and 1 so the first point measures the diference with the last point of the list (index-1) but I am guessing this will not be the case for you.

(next time include the data in a .gh file, it would make helping you a lot easier )

Thank you very much for a replay. I have checked srcipt and it seems that idea is good but it doesn’t work in all cases. Let me explain:
In your example you are treating 2 first lines as first pair of points.

It was my mistake that I didn’t explain that precise enough- First and last point has always Z=0 but they can not be consider as a one from the pair. Below you can find good example where I have frist point then 2 pairs with Z=0 and the same at the end- 2 pairs Z=0 and last point. Other then this all other pairs can be somewhere in the middle. There could be also an option that there are 2 or more pairs next to each other.

Sorry for not attaching GH file before but it is connected with tekla so it wouldn’t be usefule. Right now I just baked points to GH and save that as separate file.
I would appreciate a lot if you could help to modify script

“for point at index 2 in your example, should distance be calculated with point at index 3?”
Yes, difference in X in that case would be 1600.

point at index 2 has Z=0 and point at index 3 has Z ≠ 0
Yes, becasue Z is only showing which points belongs to pair and next or previouse point doesn’t need to have Z=0. For next and previouse only X is relevant.

does it ever happen that a single point has Z=0 and both previous point and next point have Z ≠ 0 ? what should happen in that case?

Only first and last points could be single points that have Z=0 (check also my replay to Aris below). As mentioned above previouse and next point could have Z ≠ 0.

PS. I have added also some more explanation in my replay to Aris below.

for each initial point you get a branch that indicates the value you want to calculate
so depending on its index, you know if the pair is i_with_i-1 (index 0) or i_with_i+1 (index 1)
of course head and tail have just one comparation member, so it’s always at i=0

I need all values not only first and last. So in case there would be for example 3 consecutive of zero-z pairs I need all 3 values (+ any other even if it is not consecutive).