= 2; }); if (empty($plenty)) { break; } foreach ($list as $id => &$count) { if ($count >= 2) { $powerup++; $count -= 2; } } } unset($count); $rest = array_sum($list); $powerup += intval($rest / 4); echo $powerup . "\n";