Algorithm 9. Serialization of squared euclidean distance.