<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if (($lenb > $lena) and ($lenc > $lena)) {
    echo "$a\n";
    exit;
}

$arr_a = $arr_b = $arr_c = array();

for ($i=0; $i < $lena; $i++) {
    $k = $a[$i];
    $arr_a[$k] ++;
}

for ($i=0; $i < $lenb; $i++) {
    $k = $b[$i];
    $arr_b[$k] ++;
}

for ($i=0; $i < $lenc; $i++) {
    $k = $c[$i];
    $arr_c[$k] ++;
}

$max_b = $lena;
foreach ($arr_b as $key => $value) {
    if (!isset($arr_a[$key]) or ($arr_a[$key] < $value)) {
        $max_b = 0;
        break;
    } elseif ($max_b > intval($arr_a[$key] / $value)) {
        $max_b = intval($arr_a[$key] / $value);
    }
}

$max = 0;
$col_b = $col_c = 0;
$arr_x = $arr_a;
for ($i=0; $i <= $max_b ; $i++) {

    $max_c = $lena;
    foreach ($arr_c as $key => $value) {
        if (!isset($arr_x[$key]) or ($arr_x[$key] < $value)) {
            $max_c = 0;
            break;
        } elseif ($max_c > intval($arr_x[$key] / $value)) {
            $max_c = intval($arr_x[$key] / $value);
        }
    }

    if ($max < ($i + $max_c)) {
        $max = $i + $max_c;
        $col_b = $i;
        $col_c = $max_c;
    }

    foreach ($arr_b as $key => $value) {
        $arr_x[$key] -= $value;
    }
}

$out = '';

for ($i=1; $i <= $col_b ; $i++) {
    $out .= $b;
//    echo "$b";
    foreach ($arr_b as $key => $value) {
        $arr_a[$key] -= $value;
    }
}

for ($i=1; $i <= $col_c ; $i++) {
    $out .= $c;
//    echo "$c";
    foreach ($arr_c as $key => $value) {
        $arr_a[$key] -= $value;
    }
}

foreach ($arr_a as $key => $value) {
    if ($value !== 0) {
        $out .= str_repeat("$key", $value);
//    echo str_repeat("$key", $value);
    }
}

echo "$out\n";

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if ($lenb > $lenc) {
    $x = $b;
    $b = $c;
    $c = $x;
    $x = $lenb;
    $lenb = $lenc;
    $lenc = $x;
}

$n = 0;

while ( $n <= $lena ) {

    for ($i=0; $i < $lenb; $i++) {
        $str = substr($a, $n);
        if (strpos ($str, $b[$i]) === false) {
            break;
        }
    }

    if ($i === $lenb) {
        for ($i=0; $i < $lenb; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $b[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    if ($n >= $lena) {
        break;
    }

    for ($i=0; $i < $lenc; $i++) {
        $str = substr($a, $n);
        if (strpos ($str, $c[$i]) === false) {
            break;
        }
    }

    if ($i === $lenc) {
        for ($i=0; $i < $lenc; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $c[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    break;
}

echo $a;

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if (($lenb > $lena) and ($lenc > $lena)) {
    echo "$a\n";
    exit;
}

$arr_a = $arr_b = $arr_c = array();

for ($i=0; $i < $lena; $i++) {
    $k = $a[$i];
    $arr_a[$k] ++;
}

for ($i=0; $i < $lenb; $i++) {
    $k = $b[$i];
    $arr_b[$k] ++;
}

for ($i=0; $i < $lenc; $i++) {
    $k = $c[$i];
    $arr_c[$k] ++;
}

$max_b = $lena;
foreach ($arr_b as $key => $value) {
    if (!isset($arr_a[$key]) or ($arr_a[$key] < $value)) {
        $max_b = 0;
        break;
    } elseif ($max_b > intval($arr_x[$key] / $value)) {
        $max_b = intval($arr_a[$key] / $value);
    }
}

$max = 0;
$col_b = $col_c = 0;
$arr_x = $arr_a;
for ($i=0; $i <= $max_b ; $i++) {

    $max_c = $lena;
    foreach ($arr_c as $key => $value) {
        if (!isset($arr_x[$key]) or ($arr_x[$key] < $value)) {
            $max_c = 0;
            break;
        } elseif ($max_c > intval($arr_x[$key] / $value)) {
            $max_c = intval($arr_x[$key] / $value);
        }
    }

    if ($max < ($i + $max_c)) {
        $max = $i + $max_c;
        $col_b = $i;
        $col_c = $max_c;
    }

    foreach ($arr_b as $key => $value) {
        $arr_x[$key] -= $value;
    }
}

$out = '';

for ($i=1; $i <= $col_b ; $i++) {
    $out .= $b;
    foreach ($arr_b as $key => $value) {
        $arr_a[$key] -= $value;
    }
}

for ($i=1; $i <= $col_c ; $i++) {
    $out .= $c;
    foreach ($arr_c as $key => $value) {
        $arr_a[$key] -= $value;
    }
}

foreach ($arr_a as $key => $value) {
    if ($value !== 0) {
        $out .= str_repeat("$key", $value);
    }
}

echo "$out\n";

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if (($lenb > $lena) or ($lenc > $lena)) {
    echo "$a\n";
    exit;
}

if ($lenb > $lenc) {
    $x = $b;
    $b = $c;
    $c = $x;
    $x = $lenb;
    $lenb = $lenc;
    $lenc = $x;
}

$n = 0;

while ( $n < $lena ) {

    $str = substr($a, $n);
    for ($i=0; $i < $lenb; $i++) {
        if (strpos ($str, $b[$i]) === false) {
            break;
        }
    }

    if ($i === $lenb) {
        for ($i=0; $i < $lenb; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $b[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $b[$i];
            $n ++;
        }
        continue;
    }

    if ($n >= $lena) {
        break;
    }

    $str = substr($a, $n);
    for ($i=0; $i < $lenc; $i++) {
        if (strpos ($str, $c[$i]) === false) {
            break;
        }
    }

    if ($i === $lenc) {
        for ($i=0; $i < $lenc; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $c[$i]);
//            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $c[$i];
            $n ++;
        }
        continue;
    }

    break;
}

echo "$a\n";

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if (($lenb > $lena) and ($lenc > $lena)) {
    echo "$a\n";
    exit;
}

$arr_a = $arr_b = $arr_c = array();

for ($i=0; $i < $lena; $i++) {
    $k = $a[$i];
    $arr_a[$k] ++;
}

for ($i=0; $i < $lenb; $i++) {
    $k = $b[$i];
    $arr_b[$k] ++;
}

for ($i=0; $i < $lenc; $i++) {
    $k = $c[$i];
    $arr_c[$k] ++;
}

$max_b = $lena;
foreach ($arr_b as $key => $value) {
    if (!isset($arr_a[$key]) or ($arr_a[$key] < $value)) {
        $max_b = 0;
        break;
    } elseif ($max_b > intval($arr_x[$key] / $value)) {
        $max_b = intval($arr_a[$key] / $value);
    }
}

$max = 0;
$col_b = $col_c = 0;
$arr_x = $arr_a;
for ($i=0; $i <= $max_b ; $i++) {

    $max_c = $lena;
    foreach ($arr_c as $key => $value) {
        if (!isset($arr_x[$key]) or ($arr_x[$key] < $value)) {
            $max_c = 0;
            break;
        } elseif ($max_c > intval($arr_x[$key] / $value)) {
            $max_c = intval($arr_x[$key] / $value);
        }
    }

    if ($max < ($i + $max_c)) {
        $max = $i + $max_c;
        $col_b = $i;
        $col_c = $max_c;
    }

    foreach ($arr_b as $key => $value) {
        $arr_x[$key] -= $value;
    }
}

$out = '';

for ($i=1; $i <= $col_b ; $i++) {
//    $out .= $b;
    echo "$b";
    foreach ($arr_b as $key => $value) {
        $arr_a[$key] -= $value;
    }
}

for ($i=1; $i <= $col_c ; $i++) {
//    $out .= $c;
    echo "$c";
    foreach ($arr_c as $key => $value) {
        $arr_a[$key] -= $value;
    }
}

foreach ($arr_a as $key => $value) {
    if ($value !== 0) {
//        $out .= str_repeat("$key", $value);
    echo str_repeat("$key", $value);
    }
}

echo "$out\n";

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if ($lenb > $lenc) {
    $x = $b;
    $b = $c;
    $c = $x;
    $x = $lenb;
    $lenb = $lenc;
    $lenc = $x;
}

$n = 0;

while ( $n <= $lena ) {

    for ($i=0; $i < $lenb; $i++) {
        $str = substr($a, $n);
        if (strpos ($str, $b[$i]) === false) {
            break;
        }
    }

    if ($i === $lenb) {
        for ($i=0; $i < $lenb; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $b[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    if ($n >= $lena) {
        break;
    }

    for ($i=0; $i < $lenc; $i++) {
        $str = substr($a, $n);
        if (strpos ($str, $c[$i]) === false) {
            break;
        }
    }

    if ($i === $lenc) {
        for ($i=0; $i < $lenc; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $c[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    break;
}

echo "$a\n";

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if (($lenb > $lena) or ($lenc > $lena)) {
    echo "$a\n";
    exit;
}

if ($lenb > $lenc) {
    $x = $b;
    $b = $c;
    $c = $x;
    $x = $lenb;
    $lenb = $lenc;
    $lenc = $x;
}

$n = 0;

while ( $n < $lena ) {

    $str = substr($a, $n);
    for ($i=0; $i < $lenb; $i++) {
        if (strpos ($str, $b[$i]) === false) {
            break;
        }
    }

    if ($i === $lenb) {
        for ($i=0; $i < $lenb; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $b[$i]);
//            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $b[$i];
            $n ++;
        }
        continue;
    }

    if ($n >= $lena) {
        break;
    }

    $str = substr($a, $n);
    for ($i=0; $i < $lenc; $i++) {
        if (strpos ($str, $c[$i]) === false) {
            break;
        }
    }

    if ($i === $lenc) {
        for ($i=0; $i < $lenc; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $c[$i]);
//            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $c[$i];
            $n ++;
        }
        continue;
    }

    break;
}

echo "$a\n";

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if ($lenb > $lenc) {
    $x = $b;
    $b = $c;
    $c = $x;
    $x = $lenb;
    $lenb = $lenc;
    $lenc = $x;
}

$flag = true;
$n = 0;

while ( $n <= $lena ) {

    for ($i=0; $i < $lenb; $i++) {
        $str = substr($a, $n);
        if (strpos ($str, $b[$i]) === false) {
            break;
        }
    }

    if ($i === $lenb) {
        for ($i=0; $i < $lenb; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $b[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    if ($n >= $lena) {
        break;
    }

    for ($i=0; $i < $lenc; $i++) {
        $str = substr($a, $n);
        if (strpos ($str, $c[$i]) === false) {
            break;
        }
    }

    if ($i === $lenc) {
        for ($i=0; $i < $lenc; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $c[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    break;
}

echo $a;

?>

<?php
// 490A     Командная олимпиада
$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$a = substr($input_line, 0, strlen($input_line)-2);
$lena = strlen($a);

$input_line = fgets($in);
$b = substr($input_line, 0, strlen($input_line)-2);
$lenb = strlen($b);

$input_line = fgets($in);
$c = substr($input_line, 0, strlen($input_line)-2);
$lenc = strlen($c);

if (($lenb > $lena) or ($lenc > $lena)) {
    echo "$a\n";
    exit;
}

if ($lenb > $lenc) {
    $x = $b;
    $b = $c;
    $c = $x;
    $x = $lenb;
    $lenb = $lenc;
    $lenc = $x;
}

$n = 0;

while ( $n < $lena ) {

    $str = substr($a, $n);
    for ($i=0; $i < $lenb; $i++) {
        if (strpos ($str, $b[$i]) === false) {
            break;
        }
    }

    if ($i === $lenb) {
        for ($i=0; $i < $lenb; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $b[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    if ($n >= $lena) {
        break;
    }

    $str = substr($a, $n);
    for ($i=0; $i < $lenc; $i++) {
        if (strpos ($str, $c[$i]) === false) {
            break;
        }
    }

    if ($i === $lenc) {
        for ($i=0; $i < $lenc; $i++) {
            $str = substr($a, $n);
            $pos = strpos ($str, $c[$i]);
            $x = substr($a, $n+$pos, 1);
            $a[$n+$pos] = $a[$n];
            $a[$n] = $x;
            $n ++;
        }
        continue;
    }

    break;
}

echo "$a\n";

?>


<?php
list($c) = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $c; $i++){
    list($d) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    $iAvg = ceil(array_sum($aArray)/count($aArray));
    echo $iAvg . "\n";
}

<?php
$a = trim(fgets(STDIN));
for($i = 0; $i < $a; $i++){
    $n = trim(fgets(STDIN));
    $m = explode(' ', trim(fgets(STDIN)));
    $count = 0;
    foreach($m as $v){
        $count += $v;
    }
    echo ceil($count/$n)."\n";
}

<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     $b = trim(fgets(STDIN));
     $c = explode(" ", trim(fgets(STDIN)));
     $d = ceil(array_sum($c) / $b);
     print $d . "\n";
}
?>

<?php
$q = intval(fgets(STDIN));
for ($i = 0; $i < $q; $i++) {
    $n = intval(fgets(STDIN));
    $x = array_map('intval', explode(' ', trim(fgets(STDIN))));
    echo intdiv(array_sum($x) + count($x) - 1, count($x)) . PHP_EOL;
}

<?php

while(! feof(STDIN)){
    $arr[]=fgets(STDIN);
}

$k=0;
for($i=0; $i<$arr[0]; $i++){
    $k++;
     $v=explode(" ", $arr[$i+$k+1]);
     echo $result=ceil(array_sum($v)/count($v));
     if($i!=$arr[0]-1) echo "\n";
}

?>


<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = max($b);
if($c % 2 != 0)
{
     print "NO";
}
else
{
     if($d > $c - $d)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$aArray = explode(' ', trim(fgets(STDIN)));
$iSum = array_sum($aArray);
$iMax = max($aArray);
if($iSum % 2 != 0){
    echo "NO";
} else {
    if($iMax > $iSum - $iMax){
        echo "NO";
    } else {
        echo "YES";
    }
}

<?php
	$cin = fopen("php://stdin", "r");
	$n = intval(fgets($cin));
	$s = fgets($cin);
	$a = explode(" ", $s);
	$ans = 0;$k = 0;
	for($i = 0; $i < count($a); $i++){
		$ans = $ans + intval($a[$i]);
		$k = max($k, intval($a[$i]));
	}
	if($ans % 2 == 0 && $k <= $ans - $k){
		print_r("YES");
	}
	else{
		print_r("NO");
	}
	fclose($cin);
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     $d = $b[0];
     $e = 0;
     for($x = 1; $x < $a; $x++)
     {
          $e = bcadd($e, $b[$x]);
     }
     if($d <= $e)
     {
          print "YES";
     }
     else
     {
          print "NO";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = intval(array_sum($b));
$d = max($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     if($d > $c - $d)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = max($b);
if($c % 2 == "1")
{
     print "NO";
}
else
{
     if($d > $c - $d)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = max($b);
if($c % 2 === 1)
{
     print "NO";
}
else
{
     if($d > $c - $d)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     sort($b);
     $d = array_slice($b, 0, -1);
     $e = $b[$a - 1];
     if($e > array_sum($d))
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     if($b[0] > $c - $b[0])
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = max($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     if($d > $c - $d)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     $d = $b[0];
     $e = array_sum(array_slice($b, 1));
     print $d . " " . $e . "\n";
     if($d <= $e)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     $d = $b[0];
     $e = $b[1];
     for($x = 2; $x < $a; $x++)
     {
          $e = bcadd($e, $b[$x]);
     }
     if($d > $e)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     $d = $b[0];
     $e = array_sum($b) - $d;
     if($d <= $e)
     {
          print "YES";
     }
     else
     {
          print "NO";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
$d = max($b);
if(intval($c) % 2 == 1)
{
     print "NO";
}
else
{
     if($d > $c - $d)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     $d = $b[0];
     $e = $b[1];
     for($x = 2; $x < $a; $x++)
     {
          $e = bcadd($e, $b[$x]);
     }
     if($d <= $e)
     {
          print "NO";
     }
     else
     {
          print "YES";
     }
}
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = array_sum($b);
if($c % 2 == 1)
{
     print "NO";
}
else
{
     rsort($b);
     $d = $b[0];
     $e = array_sum(array_slice($b, 1));
     if($d <= $e)
     {
          print "YES";
     }
     else
     {
          print "NO";
     }
}
?>

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
$aArray = explode(' ', trim(fgets(STDIN)));
if(array_sum($aArray) % 2 == 0){
    echo "YES";
} else {
    echo "NO";
}


<?php
error_reporting("off");
//390B: Inna, Dima, and Song
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$b = explode(" ", trim(fgets(STDIN)));
$joy = 0;
for ($i = 0; $i < $n; $i++) {
	$max = $a[$i];
	$vol = $b[$i];
	if ($max * 2 >= $vol && $vol > 1) {
		if ($vol % 2 == 0) {
			$tosquare = $vol / 2;
			$joyadd = pow($tosquare, 2);
			$joy += $joyadd;
		} else {
			$down = floor($vol / 2);
			$up = ceil($vol / 2);
			$joy += $up * $down;
		}
	} else {
		$joy--;
	}
}
echo implode(explode(",", number_format($joy, 0)));
?>


<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $a = IO::arr();
    sort($a);
    $b = $c = $d = $x = [];
    $res = 0;
    $key = $n - 1;
    $b = [$a[$key]];
    unset($a[$key]);
    $res = (array_sum($b) / count($b)) + (array_sum($a) / count($a));
    IO::line($res);

}

?>

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
for ($j = 0; $j < $n; $j++) {
    list($m) = explode(' ', trim(fgets(STDIN)));
    $aArray = explode(' ', trim(fgets(STDIN)));
    asort($aArray);
    $aAnswer = [];
    $iMax = max($aArray);
    $iAnswer = (array_sum($aArray) - $iMax)/ (count($aArray) - 1);
    echo $iAnswer + $iMax . "\n";
}

<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $a = IO::arr();
    sort($a);
    $b = $c = $d = $x = [];
    $res = 0;
    $last = $last2 = 0;
    $bool = true;
    foreach ($a as $v) {
        if ($v < 0) {
            if (isset($b[$v])) {
                $x[$v] = $v;
            } else {
                $last = $v;
                $b[$v] = $v;
            }
        } else {
            if (isset($c[$v])) {
                $d[$v] = $v;
            } else {
                $last2 = $v;
                $c[$v] = $v;
            }
        }
    }
    foreach ($d as $v) {
        $b[$v] = $v;
    }
    foreach ($x as $v) {
        $c[$v] = $v;
    }
    if (count($b) == 0) {
        $b[$last2] = $last2;
        unset($c[$last2]);
    }
    if (count($c) == 0) {
        $c[$last] = $last;
        unset($b[$last]);
    }
    $res = (array_sum($b) / count($b)) + (array_sum($c) / count($c));
    IO::line($res);

}

?>

<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $a = IO::arr();
    sort($a);
    $b = $c = $d = $x = [];
    $res = 0;
    $last = $last2 = 0;
    $bool = true;
    foreach ($a as $v) {
        if ($v < 0) {
            if (isset($b[$v])) {
                $x[$v] = $v;
            } else {
                $last = $v;
                $b[$v] = $v;
            }
        } else {
            if (isset($c[$v])) {
                $d[$v] = $v;
            } else {
                $last2 = $v;
                $c[$v] = $v;
            }
        }
    }
    if (count($b) % 2 == 1) {
        unset($b[$last]);
        $c[$last] = $last;
    }
    foreach ($d as $v) {
        $b[$v] = $v;
    }
    foreach ($x as $v) {
        $c[$v] = $v;
    }
    if (count($b) == 0) {
        $b[$last2] = $last2;
        unset($c[$last2]);
    }
    if (count($c) == 0) {
        $c[$last] = $last;
        unset($b[$last]);
    }
    $res = (array_sum($b) / count($b)) + (array_sum($c) / count($c));
    IO::line($res);

}

?>


<?php

$times = (int)trim(fgets(STDIN));
for ($idx = 0; $idx < $times; ++$idx) {
    list($ni[], $ki[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($idx = 0; $idx < $times; ++$idx) {
    $n = &$ni[$idx];
    $k = &$ki[$idx];
    --$k;
    if ($n % 2) {
        $jump_cicle = floor($n / 2);
        $jump_cnt = floor($k / $jump_cicle);
        echo ($k + $jump_cnt) % $n + 1 . PHP_EOL;
    } else {
        echo $k % $n + 1 . PHP_EOL;
    }
}

<?php

$times = (int)trim(fgets(STDIN));
for ($idx = 0; $idx < $times; ++$idx) {
    list($ni[], $ki[]) = array_map('intval', explode(' ', trim(fgets(STDIN))));
}
for ($idx = 0; $idx < $times; ++$idx) {
    $n = &$ni[$idx];
    $k = &$ki[$idx];
    --$k;
    if ($n % 2) {
        $jump_cnt = floor($n / 2);
        $k += floor($k / $jump_cnt);
    }
    echo $k % $n + 1 . PHP_EOL;
}


<?
$n=trim(fgets(STDIN));
for($i=0;$i<$n;$i++)
    $arr[]=trim(fgets(STDIN));
$alc=array('ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE');
$count=0;
foreach($arr as $val){
    if(in_array($val,$alc) || (is_numeric($val) && $val<18))
    $count++;
}
echo $count;
?>

<?php
$a = trim(fgets(STDIN));
$b = array("ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE");
array_unshift($b, " ");
unset($b[0]);
$e = 0;
for($x = 1; $x <= $a; $x++)
{
    $c = trim(fgets(STDIN));
    $d = array_search($c, $b);
    if(is_numeric($c) == TRUE)
    {
        if($c < 18)
        {
            $e++;
        }
    }
    else
    {
        if($d == TRUE)
        {
            $e++;
        }
    }
}
print $e;
?>

<?php
$n = (int)trim(fgets(STDIN));
$a = array( "ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE");
$r = 0;
for($i = 0; $i < $n;$i++){
	$t = trim(fgets(STDIN));
	if(is_numeric($t) && intval($t) < 18) $r++;
	elseif(!is_numeric($t) && in_array($t,$a)) $r++;
}
echo $r;

<?php
$str = " ABSINTH BEER BRANDY CHAMPAGNE GIN RUM SAKE TEQUILA VODKA WHISKEY WINE ";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("/ $text /", $str) || (preg_match("/^[0-9]*$/", $text)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  $text = fgets($handle);
  echo preg_match("/$text/", $str)."\n";
  $cnt += preg_match("$text", $str) || (is_integer($text)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("$text", $str) || ($text<18);
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("$text", $str) || ((int)$text>=18);
}
echo $cnt;

<?php
$str ="ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf("%s", $text);
  $cnt += preg_match("/$text/", $str) || ((int)$text>=18);
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("$text", $str) || (is_integer($text) && ($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  echo is_integer($text)."\n";
  $cnt += preg_match("$text", $str) || (is_integer($text)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("/$text/", $str) || (preg_match("/^[0-9]*$/", $text)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("/$text/", $str) || (preg_match('/[0-9]/', $str)&&$str<18);
}
echo $cnt;

<?php
$str ="ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("$text", $str) || ((int)$text>=18);
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("/$text/", $str) || (preg_match('/[0-9]/', $str)&&$text<18);
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  echo preg_match("/$text/", $str)."\n";
  $cnt += preg_match("$text", $str) || (is_integer($text)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  $text = fgets($handle);
  echo "$text is integer ".is_integer($text)."\n";
  $cnt += preg_match("$text", $str) || (is_integer($text)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  $cnt += preg_match("/$text/", $str) || (preg_match("/^[0-9]*$/", $str)&&($text<18));
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  echo "$text\n";
  $cnt += preg_match("$text", $str) || ((int)$text>=18);
}
echo $cnt;

<?php
$str = "ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin", "r");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  $text = fgets($handle);
  echo preg_match("$text", $str)."\n";
  $cnt += preg_match("$text", $str) || (is_integer($text)&&($text<18));
}
echo $cnt;

<?php
$str ="ABSINTH, BEER, BRANDY, CHAMPAGNE, GIN, RUM, SAKE, TEQUILA, VODKA, WHISKEY, WINE";
$handle = fopen("php://stdin");
fscanf($handle, "%d", $n);
$cnt = 0;
while($n--) {
  fscanf($handle, "%s", $text);
  echo "$text\n";
  $cnt += preg_match("$text", $str) || ((int)$text>=18);
}
echo $cnt;

<?php
$n = (int)trim(fgets(STDIN));
$a = array( "ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE");
$r = 0;
for($i = 0; $i < $n;$i++){
	$t = trim(fgets(STDIN));
	if(is_numeric($t) && intval($t) < 18) $r++;
	elseif(!is_numeric($t) && !in_array($t,$a)) $r++;
}
echo $r;

<?
$n=trim(fgets(STDIN));
for($i=0;$i<$n;$i++)
    $arr[]=trim(fgets(STDIN));
$alc=array('ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE');
$count=0;
foreach($arr as $val){
    if(in_array($val,$alc) || ((int)$val<18 &&(int)$val!=0))
    $count++;
}
echo $count;
?>

<?
$n=trim(fgets(STDIN));
for($i=0;$i<$n;$i++)
    $arr[]=trim(fgets(STDIN));
$alc=array('ABSINTH', 'BEER', 'BRANDY', 'CHAMPAGNE', 'GIN', 'RUM', 'SAKE', 'TEQUILA', 'VODKA', 'WHISKEY', 'WINE');
$count=0;
foreach($arr as $val){
    if(in_array($val,$alc) || ((int)$val<18 && (int)$val!=0))
    $count++;
}
echo $count;
?>


<?php
$i = trim(fgets(STDIN));
for($x = 1; $x <= $i; $x++)
{
	$s = trim(fgets(STDIN));

	$iA = substr_count($s, 'A');
    $iB = substr_count($s, 'B');
    $iC = substr_count($s, 'C');

    if ($iA + $iC == $iB) {
        echo 'Yes' . PHP_EOL;
    } else {
        echo 'No' . PHP_EOL;
    }
}

<?php
$RES = array();
$t = (int)fgets(STDIN);
while($t--)
{
	$str = trim(fgets(STDIN));
	$A = 0;
	$B = 0;
	$C = 0;
	for($i=0; $i<strlen($str); $i++)
	{
		if($str[$i] == "A")
			$A++;
		else if($str[$i] == "B")
			$B++;
		else if($str[$i] == "C")
			$C++;
	}
	if($B - $A == $C)
		array_push($RES, "YES");
	else
		array_push($RES, "NO");
}
foreach($RES as $key => $value)
	print($value."\r\n");
$end = readline();
?>

<?php

/*
 * Complete the 'fizzBuzz' function below.
 *
 * The function accepts INTEGER n as parameter.
 */

$n = intval(trim(fgets(STDIN)));
for ($i = 1; $i <= $n; $i++) {
    $inp = fgets(STDIN);
    $a = 0; $b = 0; $c = 0;

    $inp = str_split($inp);
    foreach ($inp as $in) {
        if ($in == 'A') $a++;
        if ($in == 'B') $b++;
        if ($in == 'C') $c++;
    }

    if ($b == $a+$c) echo "YES";
    else echo "NO";
    echo "\n";
}

<?php
list($n) = explode(' ', trim(fgets(STDIN)));
for ($j = 0; $j < $n; $j++) {
    list($sText) = explode(' ', trim(fgets(STDIN)));
    $aArray = [];
    $aArray["A"] = 0;
    $aArray["B"] = 0;
    $aArray["C"] = 0;
    for ($i = 0; $i < strlen($sText); $i++) {
        $aArray[$sText[$i]] += 1;
    }

//    var_dump($aArray);
    if (($aArray["A"] + $aArray["C"] == $aArray["B"])) {
        echo "YES\n";
    } else {
        echo "NO\n";
    }
}

<?php
$RES = array();
$t = (int)fgets(STDIN);
while($t--)
{
	$str = trim(readline());
	$A = 0;
	$B = 0;
	$C = 0;
	for($i=0; $i<strlen($str); $i++)
	{
		if($str[$i] == "A")
			$A++;
		else if($str[$i] == "B")
			$B++;
		else if($str[$i] == "C")
			$C++;
	}
	if($B - $A == $C)
		array_push($RES, "YES");
	else
		array_push($RES, "NO");
}
foreach($RES as $key => $value)
	print($value."\r\n");
$end = readline();
?>

<?php
$RES = array();
$t = (int)fgets(STDIN);
while($t--)
{
	$str = trim(readline());
	$A = 0;
	$B = 0;
	$C = 0;
	for($i=0; $i<strlen($str); $i++)
	{
		if($str[$i] === 'A')
			$A++;
		else if($str[$i] === 'B')
			$B++;
		else if($str[$i] === 'C')
			$C++;
	}
	if($B - $A == $C)
		array_push($RES, "YES");
	else
		array_push($RES, "NO");
}
foreach($RES as $key => $value)
	print($value."\r\n");
$end = readline();
?>

<?php
$t = (int)fgets(STDIN);
while($t--)
{
	$str = trim(readline());
	$A = 0;
	$B = 0;
	$C = 0;
	for($i=0; $i<strlen($str); $i++)
	{
		if($str[$i] === 'A')
			$A++;
		else if($str[$i] === 'B')
			$B++;
		else if($str[$i] === 'C')
			$C++;
	}
	if($B - $A == $C)
		print("YES\r\n");
	else
		print("NO\r\n");
}
$end = readline();
?>

<?php
$i = trim(fgets(STDIN));
for($x = 1; $x <= $i; $x++)
{
	$s = trim(fgets(STDIN));

	$iA = substr_count($s, 'A');
    $iB = substr_count($s, 'B');
    $iC = substr_count($s, 'C');

    if ($iA == $iB && $iA == $iC) {
        echo 'NO' . PHP_EOL;
    } else if ($iA - $iB > 0 || $iC > 0) {
        echo 'NO' . PHP_EOL;
    } else if ($iC - $iB > 0 || $iA) {
        echo 'NO' . PHP_EOL;
    } else {
        echo 'YES' . PHP_EOL;
    }

}

<?php
$i = trim(fgets(STDIN));
for($x = 1; $x <= $i; $x++)
{
	$s = trim(fgets(STDIN));

	$iA = substr_count($s, 'A');
    $iB = substr_count($s, 'B');
    $iC = substr_count($s, 'C');

    if ($iA == $iB && $iA == $iC) {
        echo 'NO' . PHP_EOL;
    } else if ($iA - $iB > 0) {
        echo 'NO' . PHP_EOL;
    } else if ($iC - $iB > 0) {
        echo 'NO' . PHP_EOL;
    } else {
        echo 'YES' . PHP_EOL;
    }
}


<?php

list($n, $m) = explode(' ', trim(fgets(STDIN)));

$input_str = trim(fgets(STDIN));

$result = $input_str;
for ($i = 0; $i < $m; $i++)
{
	list($l, $r, $c1, $c2) = explode(' ', trim(fgets(STDIN)));

	for ($j = $l - 1; $j <= $r - 1; $j++)
	{
		if ($result[$j] === $c1)
		{
			$result[$j] = $c2;
		}
	}
}

echo $result;

<?php
list($a, $b) = explode(" ", trim(fgets(STDIN)));
$c = trim(fgets(STDIN));
for($x = 1; $x <= $b; $x++)
{
     list($d, $e, $f, $g) = explode(" ", trim(fgets(STDIN)));
     for($y = $d - 1; $y <= $e - 1; $y++)
     {
          if($c[$y] == $f)
          {
               $c[$y] = $g;
          }
     }
}
print $c;
?>

<?php

$in = fopen('php://stdin', 'r');
fscanf($in, "%d%d\n", $n, $m);
$string = fread($in, $n);
for ($k = 0; $k < $m; $k++) {
    $result = fscanf($in, "\n%d %d %c %c\n", $from, $to, $needle, $replacement);
    if ($result < 0) {
        $k--;
        continue;
    }
    $from--;
    $to--;
    $string = substr($string, 0, $from) .
              strtr(substr($string, $from, $to - $from + 1), [$needle => $replacement]) .
              substr($string, $to + 1);
}
echo $string, PHP_EOL;


<?php
	$str = fgets(STDIN);

	$months = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	$dates = array();

        $len = strlen($str);

	for ($i = 0; $i + 9 < $len; ++$i) {
                $value = substr($str, $i, 10);
                if (!preg_match("/\d\d-\d\d-201(3|4|5)/", $value))
                    continue;

		$day = intval(substr($value, 0, 2));
		$month = intval(substr($value, 3, 2));

		if ($day > 0 && $month > 0 && $month < 13 && $day <= $months[$month - 1]) {
                        if (array_key_exists($value, $dates))
                            $dates[$value] += 1;
                        else
                            $dates[$value] = intval("1");
                }
	}

	$max = 0;
	$answer = "";
	foreach ($dates as $key => $value) {
		if ($max < $value) {
			$max = $value;
			$answer = $key;
		}
	}

	echo $answer;
?>

<?php
	$time=trim(fgets(STDIN));
	$months=array(31,28,31,30,31,30,31,31,30,31,30,31);
	$len=strlen($time);
	$date=array();
	for($i=0;$i+9<$len;$i++){
		$cur=substr($time,$i,10);
		if(!preg_match("/\d\d-\d\d-201(3|4|5)/",$cur)){
			continue;
		}
		$day=intval(substr($cur,0,2));
		$month=intval(substr($cur,3,2));
		if($month<=12&&$month>0&&$day>0&&$day<=$months[$month-1]){
			if(array_key_exists($cur,$date)){
				$date[$cur]++;
			}
			else $date[$cur]=1;
		}
	}
	$max=0;
	$ans="";
	foreach($date as $key=>$value){
		if($max<$value){
				$max=$value;
				$ans=$key;
			}
	}
	echo $ans.PHP_EOL;
?>


<?php

$n = (int) trim(fgets(STDIN));
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
$max = 0;
for($i =0; $i<$n; $i++){
    $current = $nums[$i];
    $max_round = $current;
    for($j=$i+1; $j<$n;$j++){
        $current= $current ^ $nums[$j];
        if($current > $max_round){
            $max_round = $current;
        }
    }
    if($max_round > $max){
        $max = $max_round;
    }
}

echo $max;

<?php

$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));

$max = $res = 0;

    for ($i = 0; $i < $n; $i++)
        for ($j = $i; $j < $n; $j++)
        {
            $res = 0;
            for ($k = $i; $k <= $j; $k++) $res ^= $a[$k];
            if ($res >= $max) $max = $res;
        }
 echo $max;

<?
$f = fopen( 'php://stdin', 'r' );

fgets($f);
$nums = explode(" ", fgets($f));

$last = array();
$otr = array();
$max = 0;
for ($i = 0; $i <= count($nums); $i++) {
for ($j = $i; $j <= count($nums); $j++) {
if (!array_search(implode("", $otr), $last)) {
$xor = getxor($otr);
if ($xor > $max) $max = $xor;
}
$otr[] = $nums[$j];
}
$otr = array();
}

echo $max;

function getxor($otr) {
$xor = 0;
foreach ($otr as $num) {
$xor ^= $num;
}
return $xor;
}

<?php

$n = (int) trim(fgets(STDIN));
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
$max = 0;
for($i =0; $i<$n-1; $i++){
    $current = $nums[$i] ^ $nums[$i+1];
    $max_round = $current;
    for($j=$i+2; $j<$n;$j++){
        $current= $current ^ $nums[$j];
        if($current > $max_round){
            $max_round = $current;
        }
    }
    if($max_round > $max){
        $max = $max_round;
    }
}
echo $max;