Input: N=3, X[] = {0, 1, 1}
Output: 2
Explanation: We can't apply operations here, e.g. If we apply operation at first three consecutive indices (Which is only possible case here), then X[] = {1, 0, 0}.It can be seen that {1, 0, 0} is not lexographically smallest than initial X[] = {0, 1, 1}. Therefore, it will not be appropriate to apply any operation and remain X[] as it is. So the minimum sum will be 2.
Input: N = 6, X[] = {0, 0, 1, 0, 1, 1}
Output: 1
Explanation: Operation 1(at three consecutive indices (3, 4, 5)): updated X[] = {0, 0, 1, 1, 0, 0}, Operation 2(at three consecutive indices (2, 3, 4)): updated X[] = {0, 0, 1, 0, 0, 0}
Now, at last X[] = {0, 0, 1, 0, 0, 0} smallest possible flexographically smallest X[], which gives the sum of X[] as 1. Therefore, output is equal to 1.