added minimum distance in an array