Description Input Output Sample Input6 5 1 3 3 3 1 2 0 1 1 2 1 2 1 0 2 3 3 2 2 0 Sample Output5 14 3 3 HintSource