Any ways to create a distance in google sheet using array formula ???

I used this formula in google sheet,
it works, but how can I make this algorithm into an array formula?

I also tried another way like
but it only shows the first result to the other rows below

En la tablas de glide hay una función para determinar la distancia la has probado? Tal vez te funcione y en las tablas los cálculos son más rápidos

You can directly use the distance column in glide or you can hardcode the formula in all cells below
With if condition