#P9517. drink
drink
Background

Problem Description
There are bottles in front of you, numbered from left to right as . Each bottle may be empty or may contain water.
You can choose a pair , and then drink up all the water in bottles . You want to drink all the remaining water on the table in one go. What is the minimum number of bottles you need to pick up?
It is possible that you do not need to pick up any bottle.
Input Format
The first line contains an integer .
The second line contains integers. The -th integer is if the -th bottle contains water, and if the -th bottle is empty.
Output Format
Output one integer , representing the minimum number of bottles to pick up.
5
0 0 0 1 0
1
6
0 0 1 1 0 1
4
Hint
Sample Explanation
In Sample , picking up bottle is enough. In total, bottle is picked up.
In Sample , picking up bottles allows you to drink all the water. In total, bottles are picked up.
Constraints
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that , and .
Translated by ChatGPT 5