Since there's a lot of discussion on this problem, I thought I'd share my technique: Problem pages: Problem statement: Analysis: So what about when there is a $1$ at one end of the array? This is the second insight, more important but enabled by the first one. If we look at the partial sums we can make without that $1$, but including its neighbour, we form a sequence that goes up to the sum of the reduced array. And in that sequence, the biggest jump in values is only $2$  that is, if say $41$ is somewhere in the middle of that sequence, then either $42$ or $43$ is next. Now if you look at the sums including the end $1$ we were previously disregarding, that will be the same values shifted by $1$, so will fill all the gaps in the previous sequence. So whenever there is a $1$ at one end of the sequence, all sums are possible up to the sum of the sequence. In case this "second insight" isn't clear, here's a practical example of a sequence with a 1 starting:
Partial sums starting from the second element (excluding the edge 1):
Partial sums starting from the 1:
and obviously the second set is each time one bigger (plus the leading 1), giving full coverage of all values from 1 to the sum. Combining these two insights: find the shorter tail of twos, and the length of that will tell you how many values (to the sequence sum) you can't make. All other values are possible. asked 24 Sep '18, 10:30

In this Problem, when test case is 2 2 1 1 1 2 2 answer should be 9 . In your test case answer is 9 but i seen so many solution which are accepted are giving answer 10 . @vijju123 answered 24 Sep '18, 11:53
Yep, the testcases for this question were too weak.
(24 Sep '18, 11:55)
I cant guarantee anything, but will see whatever I can do.
(24 Sep '18, 14:03)

How do you like my solution? answered 24 Sep '18, 10:42
OK, but a bit too terse for editorial purposes. It would perhaps have been more impressive if you have solved under the time pressure of the competition itself (before successful competition entries were visible to all). And also if you hadn't posted this solution twice to the board.
(27 Sep '18, 21:17)
