DescriptionInputOutputSample Input7 5 0 2 1 0 1 3 2 1 3 2 3 1 4 3 6 2 7 Sample Output3 0 3 2 4 HintSourceBy Xhr