Problem G
Misa
A nice part of the Roman Catholic Mass is the rite of peace
when people shake hands with their neighbours and say “peace be
with you”. Mirko has found a way to turn this ritual into his
own favor. Inside the church, there are
A seating order of the people inside the church has been given before Mirko enters. Mirko is, of course, late for the morning Mass and will sit in an empty space so that he shakes hands with as many people as he can. If there are no empty seats left, Mirko will simply give up on the idea and go to the evening Mass instead. We can assume that nobody enters the church after Mirko.
Calculate the total number of handshakes given during the morning Mass.
Input
The first line of input contains positive integers
Output
The first and only line of output should contain the required number of handshakes.
Sample Input 1 | Sample Output 1 |
---|---|
2 3 ..o o.. |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
2 2 oo oo |
6 |