dist_minmax function

Calculate minimal and maximal possible distance