Redaksiya
Let's find the sum of input integers — this is the number of coins that are heads-up. Let this sum be denoted as . To make all the coins heads-up, you need to flip the remaining coins. To make all the coins tails-up, you need to flip s coins that are currently heads-up. Thus, the answer is .
Example
There are coins heads-up.
To make all the coins heads-up, you need to flip coins. To make all the coins tails-up, you need to flip coins. The answer to the problem is coins.
Algorithm realization
Read the input data. Compute the sum of integers in the variable .
scanf("%d",&n); for(i = 0; i < n; i++) { scanf("%d",&v); s += v; }
Compute and print the result — the value of .
if (s < n - s) printf("%d\n",s); else printf("%d\n",n - s);