#arc137b. [arc137_b]Count 1's
[arc137_b]Count 1's
Problem Statement
You are given an integer sequence of length consisting of and : .
You will do the operation below exactly once.
- Choose a contiguous subsequence of and flip the elements in it: convert to and vice versa. Here, you may choose an empty subsequence, in which case the elements of do not change.
Your score will be the number of 's in . How many values are there that your score can take?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
0 1 1 0
Sample Output 1
4
There are four possible values for your score: . For example, if you flip the -nd through -th elements of , you will get , for a score of .
Sample Input 2
5
0 0 0 0 0
Sample Output 2
6
Sample Input 3
6
0 1 0 1 0 1
Sample Output 3
3