B. Bob
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
8
1 1 1 1 0 1 0 1
Output
18