const solve = (arr, count = 0) => {
let [a, b, c] = arr.sort((a, b) => b - a);
let newCount = 0;
while (b > 0) {
newCount = Math.ceil(b / 2);
count += newCount;
b -= newCount;
a -= newCount;
[a, b, c] = [a, b, c].sort((a, b) => b - a);
}
return count;
};