Bob has been assigned tasks arranged in a row, and in one day, he can perform one task. So, to perform all of the tasks, he will take days.
He has been given an array containing integers where denotes that on the day he has to perform the task.
Bob has been given an integer and has to tell the minimum days he will take to reach the configuration where there are exactly tasks between a pair of completed tasks, and all these tasks are not completed.
Help Bob to find the minimum days to reach the configuration mentioned above or print if it's impossible.
Input Format:
Output Format:
For each test case, print the minimum days to reach the configuration mentioned in the problem statement. Print if it's impossible.
Constraints:
For test case 1:
There is only one task here, so the given configuration is not possible.
For test case 2:
After the first day, Bob completes the 1st task; the configuration will be [1, 0, 0, 0].
After the second day, he completes the 2nd task; the configuration will be [1, 1, 0, 0].
After the third day, he completes the 4th task; the configuration will be [1, 1, 0, 1].
After the third day, he completes the 3rd task; the configuration will be [1, 1, 1, 1].
We can see that after the 3rd day, there is a configuration where two completed tasks have exactly one (K = 1) not completed task between them. Hence, the answer is .