Simpler distance_array function