add max distance in array