Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.Now let's imagine a typical morning in your family. You haven't woken up yet, and Mom is already going to work. She has been so hasty that she has nearly forgotten to leave the two of her darling children some money to buy lunches in the school cafeteria. She fished in the purse and found some number of coins, or to be exact, n coins of arbitrary values a1, a2, ..., an. But as Mom was running out of time, she didn't split the coins for you two. So she scribbled a note asking you to split the money equally.As you woke up, you found Mom's coins and read her note. "But why split the money equally?" — you thought. After all, your twin is sleeping and he won't know anything. So you decided to act like that: pick for yourself some subset of coins so that the sum of values of your coins is strictly larger than the sum of values of the remaining coins that your twin will have. However, you correctly thought that if you take too many coins, the twin will suspect the deception. So, you've decided to stick to the following strategy to avoid suspicions: you take the minimum number of coins, whose sum of values is strictly more than the sum of values of the remaining coins. On this basis, determine what minimum number of coins you need to take to divide them in the described manner.

The first line contains integer n (1 ≤ n ≤ 100) — the number of coins. The second line contains a sequence of n integers a1, a2, ..., an (1 ≤ ai ≤ 100) — the coins' values. All numbers are separated with spaces.

In the single line print the single number — the minimum needed number of coins.

NoteIn the first sample you will have to take 2 coins (you and your twin have sums equal to 6, 0 correspondingly). If you take 1 coin, you get sums 3, 3. If you take 0 coins, you get sums 0, 6. Those variants do not satisfy you as your sum should be strictly more that your twins' sum.In the second sample one coin isn't enough for us, too. You can pick coins with values 1, 2 or 2, 2. In any case, the minimum number of coins equals 2.

<?php
error_reporting(0);

$fp = fopen('php://stdin','r');
$count = trim( str_replace( "\r\n", '', fgets($fp) ) );
$mon = explode( " ", trim( str_replace( "\r\n", '', fgets($fp) ) ) );

if( $count == 1 ){
	echo 1;
} else {
	rsort( $mon );

	$sumMy = 0;
	for( $i = 0; $i < $count; $i++ ){
		$sumMy += $mon[$i];
		$sumBrasert = 0;
		for( $j = $i + 1; $j < $count; $j++ ){
			$sumBrasert += $mon[$j];
		}
		if( $sumMy  > $sumBrasert ){
			echo $i + 1;
			break;
		}
	}
}

fclose($fp);
?>

<?php

$cnt = trim(fgets(STDIN));
$coins = trim(fgets(STDIN));
$arr = explode(' ', $coins);
sort($arr);

for ($i = $cnt-1; $i >= 0; $i--) {
    $b1 = array_slice($arr, 0, $i);
    $b2 = array_slice($arr, $i, $cnt);
    if (array_sum($b1) < array_sum($b2)) {
        $cnt = count($b2);
        break;
    }
}

echo $cnt;

<?php

$h = fopen('php://stdin', 'r');

$res  = 0;
$sum1 = 0;
$sum2 = 0;

$num    = intval(trim(fgets($h)));
$monets = explode(' ', trim(fgets($h)));

/*
$num = mt_rand(1, 10);
for ($i = 0; $i < $num; $i++) {
    $monets[$i] = mt_rand(1, 50);
    $sum2 += $monets[$i];
}
*/

$sum2 = array_sum($monets);

rsort($monets);

foreach ($monets as $v) {
    if ($sum1 > $sum2) break;
    $res++;
    $sum2 -= $v;
    $sum1 += $v;
}

/*
var_dump($res, $sum1, $sum2);
var_dump($monets);
*/
echo $res;

<?php

$monets = readline();
$nominals = readline();
$nominals = explode(' ', $nominals);
rsort($nominals);
$sum = array_sum($nominals);
$got = 0;
$count = 0;

$i = 0;
while ($i != $monets + 1) {
    if ($got > $sum / 2) {
        echo $i;
        break;
    }

    $got += $nominals[$i];
    $i += 1;

}

<?php
    $input = array();
    while(($line = fgets(STDIN)) != false)
    {
        $input[] = trim($line);
    }

    $arr = split(' ', $input[1]);
    for ($i = 0; $i < count($arr) - 1; $i++)
    {
        for ($j = 0; $j < count($arr) - 1; $j++)
        {
            if ($arr[$j] < $arr[$j + 1])
            {
                $temp = $arr[$j];
                $arr[$j] = $arr[$j + 1];
                $arr[$j + 1] = $temp;
            }
        }
    }
    $sum = 0;
    for ($i = 0; $i < count($arr); $i++)
    {
        $sum = $sum + (int)$arr[$i];
    }
    $middle = $sum / 2;
    $real = 0;
    $count = 0;
    for ($i = 0; $i < count($arr); $i++)
    {
        $count++;
        $real = $real + $arr[$i];
        if ($real > $middle)
        {
            break;
        }
    }
    fputs(STDOUT, $count);
?>

<?php
$n = intval(trim(fgets(STDIN)));
$line = explode(' ',trim(fgets(STDIN)));
sort($line,SORT_NUMERIC);
$line = array_reverse($line);
$ans = 0;
for($i = 0; $i < count($line); $i++){
    $sum = array_sum(array_slice($line,0,$i));
    $sum_rest = array_sum(array_slice($line,$i));
//    echo "sum: $sum , sum_rest: $sum_rest" .PHP_EOL;
    if($sum > $sum_rest){
        echo $ans . PHP_EOL;
        exit;
    }
    $ans++;
}
echo count($line) . PHP_EOL;
exit;

<?php
    $f = fopen('php://stdin', 'r');
    //$f = fopen('2q.txt', 'r');
    $n = trim(fgets($f));
    $s = trim(fgets($f));

    $a = explode(" ",$s);
    sort($a);

    $s = 0;
    foreach($a as $item){
        $s+=$item;
    }

    rsort($a);
    $r = 0;
    $count = 0;
    foreach($a as $item){
        $count++;
        $r+=$item;

        if ($r > ($s - $r)) break;
    }

    echo $count;

<?php

fscanf(STDIN, "%d\n", $n);
$s = fgets(STDIN);

$coins = explode(" ", trim($s));
rsort($coins);
$totalCoinsValue = array_sum($coins);
$targetValue = $totalCoinsValue / 2;
$keptCoinValue = 0;
$keptCoinCount = 0;
foreach ($coins as $coin) {
    $keptCoinValue += $coin;
    $keptCoinCount++;

    if ($keptCoinValue > $targetValue) {
        break;
    }
}

echo $keptCoinCount;

?>

<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
rsort($a);
$v = array_sum($a)/2;
$s = $t = 0;
for($i = 0; $i < $n; ++$i) {
	$s += $a[$i];
	if($s > $v) {
		++$t;
		break;
	}
	else {
		++$t;
	}
}
echo $t;

<?php
    $file = file('php://stdin');

    $n = intval(trim($file[0]));
    $a = explode(' ', trim($file[1]));
    rsort($a);

    function sum($str, $elem)
    {
        $r = 0;
        for($i = $elem; $i < count($str); $i++)
        {
            $r += $str[$i];
        }

        return $r;
    }

    if(sum($a, 0) != 0)
    {
        $t = 0;
        $r = 1;
        for($i = 0; $i < $n; $i++)
        {
            $t += $a[$i];
            if($t > sum($a, $i + 1))
            {
                echo $r;
                break;
            }
            $r++;
        }
    }
    else echo 0;
?>

<?php
$n = trim(fgets(STDIN));
$x = trim(fgets(STDIN));
$x = explode(" ", $x);
sort($x);
$coinA = array_sum($x);
$coinB = 0;
$coin = count($x);

for ($i=0;$i<$n;$i++){
	if ($coinA - $x[$i] > $coinB + $x[$i]){
		$coinA -= $x[$i];
		$coinB += $x[$i];
		$coin--;
	}
	else{
		break;
	}
}
echo $coin;
?>

<?php
$count = trim(fgets(STDIN));
$money_value = fgets(STDIN);
$money = explode(" ", $money_value);
$no_space = trim($money[count($money) - 1]);
$money[count($money) - 1] = $no_space;
sort($money);
for ($i = 0; $i < count($money); $i++)
{
    $sum += $money[$i];
}
for ($i = count($money) - 1; $i >= 0; $i--)
{
    unset($sum_hvost);
    unset($sum_money);

    $mas_hvost[] = $money[$i];
    unset($money[$i]);
    $sum_money = array_sum($money);
    $sum_hvost = array_sum($mas_hvost);

    if ($sum_hvost > $sum_money)
    {
        echo count($mas_hvost);
        break;
    }
}
?>

<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));

rsort($a);

$total=array_sum($a);
$i=0;
$temp=0;
$hitung=0;
while ($i < count($a)) {
	if($temp > $total-$temp){
		break;
	}else{
		$temp=$temp+$a[$i];
		$hitung++;
	}
	$i++;
}
echo $hitung;

?>

<?php
// 160A Близнецы

$in = fopen("php://stdin", 'r');

$input_line = fgets($in);
$n = (int) $input_line;

$input_line = fgets($in);
$a = split(" ", $input_line);

foreach ($a as &$value) {
    $value = (int) $value;
}

sort($a);

$col = 0;
$min = 0;

for ($i = count($a)-1; $i >= 0 ; $i--) {
    $col++;
    $min += array_pop($a);
    if ($min > array_sum($a)) {
        break;
    }
}

echo $col;

?>

<?php
    $a = trim(fgets(STDIN));
    $b = explode(' ',trim(fgets(STDIN)));
   // $ball=explode(' ',trim(fgets(STDIN)));
  $sum=array_sum($b); rsort($b); $count=$b[0];  $k=1;
  for ($i=1;$i<$a;$i++)
  {

      if ($count>($sum/2)) continue;
      $count=$count+$b[$i];
      $k++;
  }
  print($k);
?>

<?php
$file = file('php://stdin');
$n = intval($file[0]);
$s = explode(' ',trim($file[1]));
$max_take = array_sum($s)/2;
$take = 0;
for ($i = 0; $i <= $n; $i++) {
    if ($take <= $max_take )
    {
        $take += max($s);
        $key = array_search(max($s), $s);
        unset($s[$key]);
        $count++;
    }
    else {break;}
}
echo $count;
?>

<?php
$cntInput = fgets(STDIN);
$arInput =  explode(' ',trim(fgets(STDIN)));
rsort($arInput);
$testVal =array_sum($arInput)/2;
for ($i=0;$i<$cntInput;$i++){
    if (($Summ += $arInput[$i])> $testVal){
        echo $i+1;
        break;
    }
}
?>

<?php

$stdin = fopen("php://stdin", "r");

$n = trim(fgets($stdin));
$line2 = trim(fgets($stdin));

$digits = explode(' ', $line2);
for($i = 0; $i < count($digits); $i++) {
    $digits[$i] = (int)$digits[$i];
}

rsort($digits);

$sums = array(0);

$result = $n;

for($i = 0; $i < count($digits); $i++) {
    if($i == 0)$sums[$i] = (int)$digits[$i];
    else $sums[$i] = $sums[$i-1] + (int)$digits[$i];
}

//var_dump($sums);

$allSum = $sums[count($digits)-1];

for($i = 0; $i < count($digits); $i++) {
    if($sums[$i] > ($allSum - $sums[$i])) {
        $result = $i+1;
        break;
    }
}

echo $result;

?>

<?php

$arr = [];
$counter = 0;
$sum = 0;
$n = (int) fgets(STDIN);
$arr = array_map('intval', explode(' ', fgets(STDIN)));

for($i=0; $i < count($arr); $i++) {
    $sum += $arr[$i];
}

$sum = $sum / 2;
sort($arr);
$sum2 = 0;
for($i = $n-1; $i >=0; $i--) {
    $sum2 += $arr[$i];
    ++$counter;
    if($sum2 > $sum) {
        break;
    }
}

echo $counter."\n";

<?
$n=trim(fgets(STDIN));
$m=explode(" ",trim(fgets(STDIN)));
sort($m);
$t=array_sum($m);
for($i=count($m)-1;$i>=0;$i--){
    $c+=$m[$i];
    $x++;
    if($c > $t-$c){echo $x;break;}
}
?>

<?php

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

rsort($a); $b = array_sum($a); $a1 = 0;
for($i=0;$i<$n;$i++){
 $a1 += $a[$i];
 if($a1 > $b-$a1) break;
}

print $i+1;
?>

<?
$fp=fopen('php://stdin', 'r');
$lines=stream_get_contents($fp);

$lines=trim($lines);
$lines=explode("\n", $lines);

$coins=explode(" ", trim($lines[1]));
rsort($coins);

$min=count($coins);

for ($i=0; $i<count($coins); $i++)
{
    $first=array_slice($coins, 0, $i);
    $second=array_slice($coins, $i);
    if(array_sum($first)>array_sum($second))
        if(count($first)<$min)
            $min=count($first);
}
echo $min;
?>

<?php

function quicksort(&$A, $p, $r)
{
        if($p<$r)
        {
                $q = partition($A, $p, $r);
                quicksort($A, $p, $q);
                quicksort($A, $q+1, $r);
        }
}

function partition(&$A, $p, $r)
{
        $x = $A[$r];
        $i=$p-1;
        for($j=$p; $j<=$r ;$j++ )
        {
                if($A[$j] >= $x)
                {
                        $i++;
                        $temp = $A[$i];
                        $A[$i] = $A[$j];
                        $A[$j] = $temp;
                }
        }
        return $i<$r ?$i : $i-1;
}

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

fscanf($stdin, '%d', $n);

$moneys = explode(' ', trim(fgets($stdin)));

$totalSum = array_sum($moneys);
$half = floor($totalSum / 2);

quicksort($moneys, 0, $n - 1);
$coins = 0;
foreach($moneys as $coin)
{
	$half -= $coin;
	$coins++;

	if($half < 0)
	{
		break;
	}
}

echo $coins;

<?php
    $arr = array();
    while(($line = fgets(STDIN)) != false)
    {
        $arr[] = $line;
    }

$digits = explode(" ", trim($arr[1]));
$sorted = array();
$sum = 0;
$count = 0;
$iteration = 0;
for ($i=0; $i<count($digits); $i++) {
    for ($j=$i; $j<count($digits)-1; $j++) {
        $iteration++;
        if ($digits[$j+1] > $digits[$i]) {
            $tmp = $digits[$j+1];
            $digits[$j+1] = $digits[$i];
            $digits[$i] = $tmp;
        }
    }
    $sum+=$digits[$i];
}

$sum2 = 0;
foreach ($digits as $value) {
    $iteration++;
    $sum2 += $value;
    $count++;
    if ($sum2 > ($sum-$sum2)) {
        break;
    }
}

    fputs(STDOUT, $count);
?>

<?php
//160A: Twins
$whatever = trim(fgets(STDIN));
//$array = "5";
$a = explode(" ", trim(fgets(STDIN))); //$a = explode(" ", $array);
rsort($a);
$me = array();
$twin = $a;
do {
    $me[] = $twin[0];
    unset($twin[0]);
    $twin = array_values($twin);
    $mesum = 0;
    $twinsum = 0;
    foreach ($me as $value) {
        $mesum = $mesum + $value;
    }
    foreach ($twin as $value) {
        $twinsum = $twinsum + $value;
    }
} while ($mesum <= $twinsum);
echo count($me);
?>

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

<?php
	$n=trim(fgets(STDIN));
	$m=explode(" ",trim(fgets(STDIN)));
	sort($m);
	$t=array_sum($m);
	for($i=count($m)-1;$i>=0;$i--){
	    $c+=$m[$i];
	    $x++;
	    if($c > $t-$c){echo $x;break;}
	}

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	rsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = 0;
	$c = 0;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum += $inp_arr[$i];
		$c++;
		if ($temp_sum > $sum - $temp_sum) break;
	}
	printf("%d", $c);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php

$numberOfConis = readline();
$coinsValue = readline();
$coinsArray = explode(" ",$coinsValue) ;
rsort($coinsArray) ;
$takenCoinsArray = array() ;
$flag = true ;

while($flag){
    $takenCoinsArray[] = array_shift($coinsArray) ;
    if(getArraySum($takenCoinsArray) > getArraySum($coinsArray)){
        $flag = false ;
    }
}

echo count($takenCoinsArray) ;

function getArraySum($array){
    $totalSum = 0 ;
    for($i = 0 ; $i < count($array) ; $i ++){
        $totalSum += $array[$i] ;
    }
    return $totalSum ;
}

<?php

    // 160 A

    //$handle = fopen('input.txt', "r");
    $handle = STDIN;

    // Ignore first line
    fgets($handle, 4096);

    $tokens = explode(" ", trim(fgets($handle, 4096)));

    sort($tokens);

    $total = 0;

    foreach($tokens as $val){

            $total += (int)$val;
    }

    $target = $total / 2;

    $coin_count = 0;
    $sum = 0;

    while($sum <= $target){

            $coin_count++;
            $sum += (int)array_pop($tokens);
    }

    echo $coin_count;

<?php
function cmp($a, $b)
{
    if ($a == $b) {
        return 0;
    }
    return ($a < $b) ? -1 : 1;
}
list($n)=explode(" ",trim(fgets(STDIN)));
$a=explode(" ",trim(fgets(STDIN)));
usort($a, "cmp");
for($i=0,$sum=0;$i<$n;$i++)
$sum+=$a[$i];
for($i--,$v=$a[$i];$i>=0;$i--)
if (2*$v>$sum) {print $n-$i;break;}
else $v+=$a[$i-1];
?>

<?php
fscanf(STDIN, "%d", $n);
$c = "";
for ($j=0; $j<$n; $j++) {
    $c .= "%d ";
}
$arr = fscanf(STDIN, $c);
rsort($arr);

$target = array_sum($arr) / 2;

$sum = 0;
$counter = 0;
for ($i=0; $i<$arr; $i++) {
	$sum += $arr[$i];
	$counter++;
	if ($sum > $target) {
		echo $counter;
		exit;
	}
}

?>

<?php
while($s = fgets(STDIN))
{
    $input .= $s;
}

$input = explode("\r\n", $input);
$input = explode(" ", $input[1]);
$coins = array();

foreach($input as $i) $coins[] = (int)$i;
$sum = array_sum($coins);
$s = 0;
$c = 0;
rsort($coins);
foreach($coins as $coin)
{
    $s += $coin;
    $c++;
    if($s > ($sum-$s)) break;
}

echo $c;

<?php

while($s = fgets(STDIN)){
    $input .= $s;
}

$directory = '/';
$input = explode("\r\n", $input);
$s = $input[1];
/*/

$s = '2 1 2';

//*/
$m = array();

$s = explode(' ', $s);
foreach($s as $v) {
    $m[] = intval($v);
}

$total = array_sum($m);
if(($total % 2) == 0) {
    $need = ($total/2)+1;
} else {
    $need = ceil($total/2);
}

$mcount = 0;
$summ = 0;
rsort($m);
foreach ($m as $key => $value) {
    $mcount += 1;
    $summ += $value;
    if($summ >= $need) break;
}

echo $mcount;

<?php
	$take = 0;
	$temp = 0;
	$left = 0;
	$i = 0;

	$coin_count = trim(fgets(STDIN));
	$coins = explode(" ",trim(fgets(STDIN)));
	$coins_sum=array_sum($coins);
	rsort($coins);
	$left = $coins_sum - $temp;
	while($coin_count > 0)
	{

		if($temp > $left)
			break;
		else
		{
			$temp = $temp + $coins[$i];
			$left = $coins_sum - $temp;
			$take++;
		}
		$i++;
		$coin_count--;
	}
	echo $take;
?>

<?php
$n = trim(fgets(STDIN));

$InStr = trim(fgets(STDIN));
$Money = explode(' ', $InStr);

rsort($Money);

for($i = 0; $i < $n; $i++){
    $ar1 = array_slice($Money, 0, $i);
    $ar2 = array_slice($Money, $i);

    if(array_sum($ar1) > array_sum($ar2)){
        break;
    }
}

echo $i . "\r\n";
?>

<?php
while($s = fgets(STDIN)){
    $input .= $s;
}
$input = explode("\r\n", $input);
$nums = explode(' ', $input[1]);

foreach($nums as $value) {
    $summ = $summ + $value;
}
rsort($nums);
foreach($nums as $value) {
    $result++;
    $res = $res + $value;
    if ($res > ($summ/2)) {
        echo $result;
        die();
    }
}
?>

<?php

function dd(...$args)
{
    var_dump(...$args);
    die;
}

define('TXTIN', fopen('input.txt', 'r'));
define('TXTOUT', fopen('output.txt', 'w'));

//$input = TXTIN;
$input = STDIN;
//$output = TXTOUT;
$output = STDOUT;

function foo($a)
{
    rsort($a);

    $me = 0;
    $bro = array_sum($a);
    $i = 0;

    while ($me <= $bro && !empty($a)) {
        $me += $a[$i];
        $bro -= $a[$i];
        unset($a[$i]);
        $i++;
    }

    return $i;
}

$r = 0;

list($n) = fscanf($input, "%d\n");

$a = fscanf($input, trim(str_repeat("%d ", $n)));

$r = foo($a);

fwrite($output, $r);

<?php

$dir = fopen("php://stdin", 'r');
$input = stream_get_contents($dir);

$arr = explode(PHP_EOL, $input);
$numbers = explode(" ", $arr[1]);
rsort($numbers);
$k=0;
$sum=0;

do {
    $first = array_shift($numbers);
    $sum += (int) $first;
    $k++;
} while($sum <= array_sum($numbers));

echo $k;

<?php
fscanf(STDIN,"%s",$n);
$a = explode(" ", trim(fgets(STDIN)));
$out = [];
do {
  $out[] = takeMax($a);
} while(array_sum($a) >= array_sum($out));
echo count($out);

function takeMax(&$array) {
  $max = $array[0];
  $id = 0;
  for ($i = 0; $i < count($array); $i++)
    if ($max < $array[$i]) {
      $max = $array[$i];
      $id = $i;
    }
  unset($array[$id]);
  sort($array);
  return $max;
}

<?php
    $n = trim(fgets(STDIN));
    $arr = explode(" ", trim(fgets(STDIN)));
    rsort($arr);
    $all_sum = array_sum($arr);
    for($i = 0; $i < $n; ++$i)
    {
        $sum += $arr[$i];
        $count++;
        if($sum > $all_sum - $sum)
        {
            echo $count;
            break;
        }
    }
?>

<?php

$n = (int) readline();

$nums = array_map('intval', explode(' ', readline()));
$sum = 0;
foreach($nums as $num){
    $sum += $num;
}

rsort($nums);
$count = 0;
$tmp = 0;
for($i=0;$i<$n;$i++){
    $count++;
    $tmp += $nums[$i];
    if($tmp > ($sum/2)){
        break;
    }
}

echo $count;

<?php
$n = trim(fgets(STDIN));
$coin = explode(" ",trim(fgets(STDIN)));
rsort($coin);
$summ=0;
$average=0;
for ($i=0; $i<$n;$i++)
{
    $average+=$coin[$i];
}
$average=$average/2;
for ($i=0; $i<$n;$i++)
{
    $summ+=$coin[$i];
    if ($summ>$average)
    {
        echo $i+1;
        break;
    }
}

<?php

fscanf(STDIN, '%d/n', $number);
$twins = trim(fgets(STDIN));
$arr_twins = preg_split('/\s/', $twins, -1, PREG_SPLIT_NO_EMPTY);

$buf = 0;
for ($i = 0; $i < count($arr_twins)-1; $i++) {
    for ($j = 0; $j < count($arr_twins)-$i-1; $j++) {
        if ($arr_twins[$j] > $arr_twins[$j+1]) {
            $buf = $arr_twins[$j+1];
            $arr_twins[$j+1] = $arr_twins[$j];
            $arr_twins[$j] = $buf;
        }
    }
}
$sum1 = 0;
for ($i = 0; $i < count($arr_twins); $i++) {
    $sum1 = $sum1 + $arr_twins[$i];
}
$k = count($arr_twins)-1;
$ch = 0;
$sum2 = 0;
do {
    $sum1 = $sum1 - $arr_twins[$k];
    $sum2 = $sum2 + $arr_twins[$k];
    $k = $k-1;
    $ch = $ch + 1;
}
while ($sum2 <= $sum1);
print($ch);

<?php

$cnt = '2';
$coins = '3 3';
$arr = explode(' ', $coins);
sort($arr);

for ($i = $cnt-1; $i >= 0; $i--) {
    $b1 = array_slice($arr, 0, $i);
    $b2 = array_slice($arr, $i, $cnt);
    if (array_sum($b1) < array_sum($b2)) {
        $cnt = count($b2);
        break;
    }
}

echo $cnt;

<?php

$monets = readline();
$nominals = readline();
$nominals = explode(' ', $nominals);
rsort($nominals);
$sum = array_sum($nominals);
$got = 0;
$count = 0;

$i = 0;
while ($i != $monets) {
    if ($got > $sum / 2) {
        echo $i;
        break;
    }

    $got += $nominals[$i];
    $i += 1;

}

<?php
    $f = fopen('php://stdin', 'r');
    //$f = fopen('2q.txt', 'r');
    $n = trim(fgets($f));
    $s = trim(fgets($f));

    $a = explode(" ",$s);
    sort($a);

    $sum = 0;
    foreach($a as $item){
        $sum+=$item;
    }

    $midle = $sum/2;

    rsort($a);

    $min = 0;
    $b = $a;
    $count = 0;

    if ($a[0]>$midle){
        echo 1;exit;
    }

    foreach ($a as $item) {
        if (($min+$item)<=$midle){
            $min = $min+$item;
            //var_dump($item);
            $count++;
        }
    }

    if ($min <= $midle){
        echo (++$count);
    };

<?php

fscanf(STDIN, "%d\n", $n);
$s = fgets(STDIN);

$coins = explode(" ", trim($s));
sort($coins);
$totalCoinsValue = array_sum($coins);
$targetValue = $totalCoinsValue / 2;
$keptCoinValue = 0;
$keptCoinCount = 0;
foreach ($coins as $coin) {
	$keptCoinValue += $coin;
	$keptCoinCount++;

	if ($keptCoinValue > $targetValue) {
		break;
	}
}

echo $keptCoinCount;

?>

<?php
$count = trim(fgets(STDIN));
$money_value = fgets(STDIN);

$money = explode(" ", $money_value);
sort($money);

for ($i = 0; $i < count($money); $i++)
{
    $sum += $money[$i];
}
unset($money[count($money) - 1]);
for ($i = count($money) - 1; $i >= 0; $i--)
{
    unset($sum_hvost);
    unset($sum_money);

    $mas_hvost[] = $money[$i];
    unset($money[$i]);
    $sum_money = array_sum($money);
    $sum_hvost = array_sum($mas_hvost);

    if ($sum_hvost > $sum_money)
    {
        echo count($mas_hvost);
        break;
    }
}
?>

<?php
$count = trim(fgets(STDIN));
$money_value = fgets(STDIN);

$money = explode(" ", $money_value);
sort($money);

for ($i = 0; $i < count($money); $i++)
{
    $sum += $money[$i];
}

for ($i = count($money) - 1; $i >= 0; $i--)
{
    unset($sum_hvost);
    unset($sum_money);

    $mas_hvost[] = $money[$i];
    unset($money[$i]);
    $sum_money = array_sum($money);
    $sum_hvost = array_sum($mas_hvost);

    if ($sum_hvost > $sum_money)
    {
        echo count($mas_hvost);
        //print_r($mas_hvost);

        break;
    }
}

?>

<?php
$count = trim(fgets(STDIN));
$money_value = fgets(STDIN);

$money = explode(" ", $money_value);
sort($money);

for ($i = 0; $i < count($money); $i++)
{
    $sum += $money[$i];
}

for ($i = count($money) - 1; $i >= 0; $i--)
{
    unset($sum_hvost);
    unset($sum_money);

    $mas_hvost[] = $money[$i];
    unset($money[$i]);
    $sum_money = array_sum($money);
    $sum_hvost = array_sum($mas_hvost);

    if ($sum_hvost > $sum_money)
    {
        echo count($mas_hvost);
        break;
    }
}

?>

<?
$n=trim(fgets(STDIN));
$m=explode(" ",trim(fgets(STDIN)));
$t=array_sum($m);
for($i=count($m)-1;$i>=0;$i--){
    $c+=$m[$i];
    $x++;
    if($c > $t-$c){echo $x;break;}
}
?>

<?
$n=trim(fgets(STDIN));
$m=explode(" ",trim(fgets(STDIN)));
rsort($m);
$t=array_sum($m);
for($i=count($m)-1;$i>=0;$i--){
    $c+=$m[$i];
    $x++;
    if($c > $t-$c){echo $x;break;}
}
?>

<?php

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

rsort($a); $b = array_sum($a); $a1 = 0;
for($i=1;$i<=$n;$i++){
 $a1 += $a[$i];
 if($a1 > $b-$a1) break;
}

print $i;
?>

<?php
//160A: Twins
//$whatever = trim(fgets(STDIN));
$array = "3 3";
$a = explode(" ", trim(fgets(STDIN))); $a = explode(" ", $array);
rsort($a);
$me = array();
$twin = $a;
do {
    $me[] = $twin[0];
    unset($twin[0]);
    $twin = array_values($twin);
    $mesum = 0;
    $twinsum = 0;
    foreach ($me as $value) {
        $mesum = $mesum + $value;
    }
    foreach ($twin as $value) {
        $twinsum = $twinsum + $value;
    }
} while ($mesum <= $twinsum);
echo count($me);
?>

<?php
	$n = fgets(STDIN);
	$var = explode(' ',fgets(STDIN));
    $sub = 0; $x = 0;
	rsort($var);
	$sum = array_sum($var);
	foreach ($var as $val) {
		$sub += $val;
		$x++;
		if($sub > ( $sum - $sub )){
			echo $x;
			break;
		}
	}

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = $sum;
	$pos = 0;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum -= $inp_arr[$i];
		$pos = $i;
		if ($temp_sum < (int)$sum / 2) break;
	}
	printf("%d", $pos + 1);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = 0;
	$pos = 0;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum += $inp_arr[$i];
		$pos = $i;
		if ($temp_sum > $sum - $temp_sum) break;
	}
	printf("%d", $pos + 1);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = $sum;
	$pos = 0;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum += $inp_arr[$i];
		$pos = $i;
		if ($temp_sum > $sum - $temp_sum) break;
	}
	printf("%d", $pos + 1);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = 0;
	$c = 0;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum += $inp_arr[$i];;
		$c++;
		if ($temp_sum > $sum - $temp_sum) break;
	}
	printf("%d", $c);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	//$Scanner = new Scanner("php://stdin");
	$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_pos = 0;
	$temp_sum = $sum;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum -= $inp_arr[$i];
		$pos = $i;
		if ($temp_sum < (int)$sum / 2) break;
	}
	printf("%d", $pos + 1);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = $sum;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum -= $inp_arr[$i];
		$pos = $i;
		if ($temp_sum < (int)$sum / 2) break;
	}
	printf("%d", $pos + 1);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = (int)$Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		$inp_arr[] = (int)$Scanner->Scan();
	}
	arsort($inp_arr);
	$sum = array_sum($inp_arr);
	$temp_sum = $sum;
	$pos = 0;
	for ($i = 0; $i < $inp_n; $i++) {
		$temp_sum -= $inp_arr[$i];
		$pos = $i;
		if ($temp_sum < $sum - $temp_sum) break;
	}
	printf("%d", $pos + 1);
	$Scanner->close();
}

ob_end_clean();
solve();

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

/*
====begin=====

//input    $inp_ or upper
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $^Upper

====end=======

===== class begin =====

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}

class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
===== class end ======

=== function begin ===

function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}

function num_printf($i){
	if (is_float($i)) {
		printf("%.0f", $i);
	}
	if (is_int($i)) {
		printf("%d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}

== function end ======
*/

?>

<?php

    // 160 A

    //$handle = fopen('input.txt', "r");
    $handle = STDIN;

    // Ignore first line
    fgets($handle, 4096);

    $tokens = explode(" ", trim(fgets($handle, 4096)));

    sort($tokens);

    $total = 0;

    foreach($tokens as $val){

            $total += (int)$val;
    }

    $target = $total / 2;

    $coin_count = 0;
    $sum = 0;

    while($sum < $target){

            $coin_count++;
            $sum += (int)array_pop($tokens);
    }

    echo $coin_count;

var calendars=[
	[
		['9:00', '10:30'],['12:00', '13:00'],['16:00', '18:00']
	],
	[
		['10:00', '11:30'],['12:30', '14:30'],['14:30', '15:00']
	]
];

var bounds=[
	[
		['9:00', '20:00']
	],
	[
		['10:00', '18:30']
	]
];

var availableBlocks= [];

var duration=30;

//setting start and end of the day
var startDay = new Date();
startDay.setHours(0,0,0);
var endDay = new Date();
endDay.setHours(24,0,0);

var numOfCalendars = calendars.length;
var numOfBounds = bounds.length;

for (var i=0; i<numOfCalendars; i++) {
	findBetween(calendars[i]);
}

function findBetween(calendar) {
	var meetings = calendar.length;
	var block = [];
	for (var i=1; i<meetings; i++) {
		var end = convTime(calendar[i-1][1]);
		var start = convTime(calendar[i][0]);
		var num = numOfAvailableBlocks(end, start);
		for (var j=1; j<=num; j++) {
			var availDate = new Date(end);
			availDate.setMinutes(availDate.getMinutes() + duration);
			block.push([dateToHour(end), dateToHour(availDate)]);
			end.setMinutes(end.getMinutes() + duration);
		}
	}
	availableBlocks.push(block);
}

console.log(availableBlocks);

function convTime(timeString) {
	var time = new Date();
	var timeArr = timeString.split(":");
	time.setHours(timeArr[0], timeArr[1], 0);
	return time;
}

function numOfAvailableBlocks(date1, date2) {
	return Math.floor((date2-date1)/1000/60/30);
}

function dateToHour(date) {
	return date.getHours() + ":" + (date.getMinutes()<10?'0':'') + date.getMinutes();
}

<?php
fscanf(STDIN, "%d", $n);
$c = "";
for ($j=0; $j<$n; $j++) {
    $c .= "%d ";
}
$arr = fscanf(STDIN, $c);

$target = array_sum($arr) / 2;

$sum = 0;
$counter = 0;
for ($i=0; $i<$arr; $i++) {
	$sum += $arr[$i];
	$counter++;
	if ($sum > $target) {
		echo $counter;
		exit;
	}
}

?>

<?php

while($s = fgets(STDIN)){
    $input .= $s;
}

$directory = '/';
$input = explode("\r\n", $input);
$s = $input[1];
/*/

$s = '2 1 2';

//*/
$m = array();

$s = explode(' ', $s);
foreach($s as $v) {
    $m[] = intval($v);
}

$total = array_sum($m);
if(($total % 2) == 0) {
    $need = ($total/2)+1;
} else {
    $need = ceil($total/2);
}

$mcount = 0;
$summ = 0;
rsort($m);
foreach ($m as $key => $value) {
    $mcount += 1;
    $summ += $value;
    if($summ > $need) break;
}

echo $mcount;

<?php
	$take = 0;
	$temp = 0;
	$left = 0;
	$i = 0;
	$coin_count = trim(fgets(STDIN));
	$coins = explode(" ",trim(fgets(STDIN)));
	$coins_sum=array_sum($coins);
	rsort($coins);
	$left = $coins_sum - $temp;
	while($coin_count > 0)
	{

		if($temp > $left)
			break;
		else
		{
			$temp = $temp + $coins[$i];
			$left = $left - $temp;
			$take++;
		}
		$i++;
		$coin_count--;
	}
	echo $take;
?>

<?php
	$take = 0;
	$temp = 0;
	$left = 0;
	$i = 0;
	$coin_count = trim(fgets(STDIN));
	$coins = explode(" ",trim(fgets(STDIN)));
	$coins_sum=array_sum($coins);
	rsort($coins);
	$left = $coins_sum - $temp;
	while($coin_count > 0)
	{

		if($temp > $left)
			break;
		else
		{
			$temp = $temp + $count[$i];
			$left = $left - $temp;
			$take++;
		}
		$i++;
		$coin_count--;
	}
	echo $take;
?>

<?php
while($s = fgets(STDIN)){
    $input[]= $s;
}
$count = $input[0];
$nums = explode(' ', $input[1]);
$summ = 0;
$result = 0;
$res = 0;

foreach($nums as $value) {
    $summ = $summ + $value;
}
rsort($nums);
foreach($nums as $value) {
    $result++;
    $res = $res + $value;
    if ($res > ($summ/2)) {
        echo $result;
        die();
    }
}
?>

<?php
while($s = fgets(STDIN)){
    $input[]= $s;
}
$count = $input[0];
$nums = explode(' ', $input[1]);

foreach($nums as $value) {
    $summ = $summ + $value;
}
rsort($nums);
foreach($nums as $value) {
    $result++;
    $res = $res + $value;
    if ($res > ($summ/2)) {
        echo $result;
        die();
    }
}
?>

<?php

$dir = fopen("php://stdin", 'r');
$input = stream_get_contents($dir);

$arr = explode(PHP_EOL, $input);
$numbers = explode(" ", $arr[1]);
sort($numbers);
$k=0; $sum=0;

do{
    $first = array_shift($numbers);
    $sum += (int)$first;
    $k++;
}
while($sum < array_sum($numbers));

echo $k;

<?php
    $n = fgets(STDIN);
    $arr = explode(" ", fgets(STDIN));
    rsort($arr);
    $sum = 0; $count = 0; $all_sum = 0;
    for($i = 0; $i < $n; ++$i)
    {
        $all_sum += $arr[$i];
    }
    for($i = 0; $i < $n; ++$i)
    {
        $sum += $arr[$i];
        $count++;
        if($sum > $all_sum - $sum)
        {
            break;
        }
    }
    echo $count;
?>

<?php
    $n = fgets(STDIN);
    $arr = explode(" ", fgets(STDIN));
    sort($arr);
    $sum = 0; $count = 0; $all_sum = 0;
    for($i = 0; $i < $n; ++$i)
    {
        $all_sum += $arr[$i];
    }
    for($i = 0; $i < $n; ++$i)
    {
        $sum += $arr[$i];
        $count++;
        if($sum > $all_sum - $sum)
        {
            break;
        }
    }
    echo $count;
?>

<?php
    $n = fgets(STDIN);
    $arr = explode(" ", fgets(STDIN));
    sort($arr);
    $sum = 0; $count = 0; $all_sum = 0;
    for($i = 0; $i < $n; ++$i)
    {
        $all_sum += $arr[$i];
    }
    for($i = 0; $i < $n; ++$i)
    {
        $sum += $arr[$i];
        $count++;
        if($sum >= $all_sum - $sum)
        {
            break;
        }
    }
    echo $count;
?>

<?php
    $n = fgets(STDIN);
    $arr = explode(" ", fgets(STDIN));
    rsort($arr);
    $all_sum = array_sum($arr);
    for($i = 0; $i < $n; ++$i)
    {
        $sum += $arr[$i];
        $count++;
        if($sum > $all_sum - $sum)
        {
            echo $count;
            break;
        }
    }
?>


Pashmak has fallen in love with an attractive girl called Parmida since one year ago...Today, Pashmak set up a meeting with his partner in a romantic garden. Unfortunately, Pashmak has forgotten where the garden is. But he remembers that the garden looks like a square with sides parallel to the coordinate axes. He also remembers that there is exactly one tree on each vertex of the square. Now, Pashmak knows the position of only two of the trees. Help him to find the position of two remaining ones.

The first line contains four space-separated x1, y1, x2, y2 ( - 100 ≤ x1, y1, x2, y2 ≤ 100) integers, where x1 and y1 are coordinates of the first tree and x2 and y2 are coordinates of the second tree. It's guaranteed that the given points are distinct.

If there is no solution to the problem, print -1. Otherwise print four space-separated integers x3, y3, x4, y4 that correspond to the coordinates of the two other trees. If there are several solutions you can output any of them.  Note that x3, y3, x4, y4 must be in the range ( - 1000 ≤ x3, y3, x4, y4 ≤ 1000).

<?php

function FindTree($axes){

    $axes = explode(" ", $axes);
    $x1 = $axes[0];
    $y1 = $axes[1];
    $x2 = $axes[2];
    $y2 = $axes[3];

    $length = abs($x2-$x1);
    $width  = abs($y2-$y1);

    //echo $length;
   // echo  $width;
    if($width==0 || $length==0 || $length==$width){
        if($width==0 ){
            $x3 = $x1;
            $y3 = $y1+$length;
            $x4 = $x2;
            $y4 = $y2+$length;
        }
        elseif ($length==0 ){
            $x3 = $x1+$width;
            $y3 = $y1;
            $x4 = $x2+$width;
            $y4 = $y2;
        }
        elseif ($length==$width) {
            $x3 = $x1;
            $y3 = $y2;
            $x4 = $x2;
            $y4 = $y1;
        }

         echo $x3." ".$y3." ".$x4." ".$y4;
    }
    else
        echo "-1";

}

$axes = trim(fgets(STDIN));

FindTree($axes);


An array $$$[b_1, b_2, \ldots, b_m]$$$ is a palindrome, if $$$b_i = b_{m+1-i}$$$ for each $$$i$$$ from $$$1$$$ to $$$m$$$. Empty array is also a palindrome.An array is called kalindrome, if the following condition holds: It's possible to select some integer $$$x$$$ and delete some of the elements of the array equal to $$$x$$$, so that the remaining array (after gluing together the remaining parts) is a palindrome. Note that you don't have to delete all elements equal to $$$x$$$, and you don't have to delete at least one element equal to $$$x$$$.For example :   $$$[1, 2, 1]$$$ is kalindrome because you can simply not delete a single element.  $$$[3, 1, 2, 3, 1]$$$ is kalindrome because you can choose $$$x = 3$$$ and delete both elements equal to $$$3$$$, obtaining array $$$[1, 2, 1]$$$, which is a palindrome.  $$$[1, 2, 3]$$$ is not kalindrome. You are given an array $$$[a_1, a_2, \ldots, a_n]$$$. Determine if $$$a$$$ is kalindrome or not.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — elements of the array. It's guaranteed that the sum of $$$n$$$ over all test cases won't exceed $$$2 \cdot 10^5$$$.

For each test case, print YES if $$$a$$$ is kalindrome and NO otherwise. You can print each letter in any case.

NoteIn the first test case, array $$$[1]$$$ is already a palindrome, so it's a kalindrome as well.In the second test case, we can choose $$$x = 2$$$, delete the second element, and obtain array $$$[1]$$$, which is a palindrome.In the third test case, it's impossible to obtain a palindrome.In the fourth test case, you can choose $$$x = 4$$$ and delete the fifth element, obtaining $$$[1, 4, 4, 1]$$$. You also can choose $$$x = 1$$$, delete the first and the fourth elements, and obtain $$$[4, 4, 4]$$$.

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

function del($arr, $j) {
  $arrNew = [];
  for ($i = 0; $i < count($arr); $i++) {
    if ($arr[$i] !== $j) {
      $arrNew[] = $arr[$i];
    }
  }
  return $arrNew;
}

function check($arr) {
  $reversed = array_reverse($arr);
  if ($arr == $reversed) { return 'YES'; }
  else { return 0; }
}

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $arr = explode(" ", trim(fgets($file)));

  for ($j = 0; $j < count($arr); $j++) {

    if ($arr[$j] !== $arr[$n - 1 - $j]) {
      $x = $arr[$j];
      $y = $arr[$n - 1 - $j];
      break;
    }
  }

  $newArr1 = del($arr, $x);
  $newArr2 = del($arr, $y);

  $ans1 = check($newArr1);
  $ans2 = check($newArr2);

  if ($ans1 !== 0 || $ans2 !== 0) {
    echo 'YES'.PHP_EOL;
  } else {
    echo 'NO'.PHP_EOL;
  }
}

?>


A bracket sequence is a string containing only characters "(" and ")".A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()", "(())" are regular (the resulting expressions are: "(1)+(1)", "((1+1)+1)"), and ")(" and "(" are not.You are given $$$n$$$ bracket sequences $$$s_1, s_2, \dots , s_n$$$. Calculate the number of pairs $$$i, j \, (1 \le i, j \le n)$$$ such that the bracket sequence $$$s_i + s_j$$$ is a regular bracket sequence. Operation $$$+$$$ means concatenation i.e. "()(" + ")()" = "()()()".If $$$s_i + s_j$$$ and $$$s_j + s_i$$$ are regular bracket sequences and $$$i \ne j$$$, then both pairs $$$(i, j)$$$ and $$$(j, i)$$$ must be counted in the answer. Also, if $$$s_i + s_i$$$ is a regular bracket sequence, the pair $$$(i, i)$$$ must be counted in the answer.

The first line contains one integer $$$n \, (1 \le n \le 3 \cdot 10^5)$$$ — the number of bracket sequences. The following $$$n$$$ lines contain bracket sequences — non-empty strings consisting only of characters "(" and ")". The sum of lengths of all bracket sequences does not exceed $$$3 \cdot 10^5$$$.

In the single line print a single integer — the number of pairs $$$i, j \, (1 \le i, j \le n)$$$ such that the bracket sequence $$$s_i + s_j$$$ is a regular bracket sequence.

NoteIn the first example, suitable pairs are $$$(3, 1)$$$ and $$$(2, 2)$$$.In the second example, any pair is suitable, namely $$$(1, 1), (1, 2), (2, 1), (2, 2)$$$.


Allen dreams of one day owning a enormous fleet of electric cars, the car of the future! He knows that this will give him a big status boost. As Allen is planning out all of the different types of cars he will own and how he will arrange them, he realizes that he has a problem. Allen's future parking lot can be represented as a rectangle with $$$4$$$ rows and $$$n$$$ ($$$n \le 50$$$) columns of rectangular spaces, each of which can contain at most one car at any time. He imagines having $$$k$$$ ($$$k \le 2n$$$) cars in the grid, and all the cars are initially in the second and third rows. Each of the cars also has a different designated parking space in the first or fourth row. Allen has to put the cars into corresponding parking places.  Illustration to the first example. However, since Allen would never entrust his cars to anyone else, only one car can be moved at a time. He can drive a car from a space in any of the four cardinal directions to a neighboring empty space. Furthermore, Allen can only move one of his cars into a space on the first or fourth rows if it is the car's designated parking space. Allen knows he will be a very busy man, and will only have time to move cars at most $$$20000$$$ times before he realizes that moving cars is not worth his time. Help Allen determine if he should bother parking his cars or leave it to someone less important.

The first line of the input contains two space-separated integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 50$$$, $$$1 \le k \le 2n$$$), representing the number of columns and the number of cars, respectively. The next four lines will contain $$$n$$$ integers each between $$$0$$$ and $$$k$$$ inclusive, representing the initial state of the parking lot. The rows are numbered $$$1$$$ to $$$4$$$ from top to bottom and the columns are numbered $$$1$$$ to $$$n$$$ from left to right. In the first and last line, an integer $$$1 \le x \le k$$$ represents a parking spot assigned to car $$$x$$$ (you can only move this car to this place), while the integer $$$0$$$ represents a empty space (you can't move any car to this place). In the second and third line, an integer $$$1 \le x \le k$$$ represents initial position of car $$$x$$$, while the integer $$$0$$$ represents an empty space (you can move any car to this place). Each $$$x$$$ between $$$1$$$ and $$$k$$$ appears exactly once in the second and third line, and exactly once in the first and fourth line.

If there is a sequence of moves that brings all of the cars to their parking spaces, with at most $$$20000$$$ car moves, then print $$$m$$$, the number of moves, on the first line. On the following $$$m$$$ lines, print the moves (one move per line) in the format $$$i$$$ $$$r$$$ $$$c$$$, which corresponds to Allen moving car $$$i$$$ to the neighboring space at row $$$r$$$ and column $$$c$$$. If it is not possible for Allen to move all the cars to the correct spaces with at most $$$20000$$$ car moves, print a single line with the integer $$$-1$$$.

NoteIn the first sample test case, all cars are in front of their spots except car $$$5$$$, which is in front of the parking spot adjacent. The example shows the shortest possible sequence of moves, but any sequence of length at most $$$20000$$$ will be accepted.In the second sample test case, there is only one column, and the cars are in the wrong order, so no cars can move and the task is impossible.


Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing numbers 1 and 0. The boys are very superstitious. They think that they can do well at the Olympiad if they begin with laying all the cards in a row so that:  there wouldn't be a pair of any side-adjacent cards with zeroes in a row;  there wouldn't be a group of three consecutive cards containing numbers one. Today Vanya brought n cards with zeroes and m cards with numbers one. The number of cards was so much that the friends do not know how to put all those cards in the described way. Help them find the required arrangement of the cards or else tell the guys that it is impossible to arrange cards in such a way.

The first line contains two integers: n (1 ≤ n ≤ 106) — the number of cards containing number 0; m (1 ≤ m ≤ 106) — the number of cards containing number 1.

In a single line print the required sequence of zeroes and ones without any spaces. If such sequence is impossible to obtain, print -1.

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    assert_options(ASSERT_ACTIVE, 1);
    assert_options(ASSERT_BAIL, 1);
    $test = <<<INPUT
1000000 9999990
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

$s = trim(fgets(MY_STDIN));
list($c0, $c1) = explode(' ', $s);

function solve($c0, $c1) {
    $n1 = $c0 - 1; $in = 0;
    $rest1 = $c1 - $n1;
    $res = '';
    if ($rest1 < 0) {
        return "-1";
    }

    if ($n1 == 0) {
        $n2 = 0;
    } else if ($rest1 > $n1) {
        $n2 = $n1;
        $rest1 = $rest1 - $n1;
    } else {
        $n2 = $rest1;
        $rest1 = 0;
    }

    if ($rest1 > 4) {
        return "-1";
    } else if ($rest1) {
        $res .='1'; $rest1--;
        if ($rest1) {
            $res .='1'; $rest1--;
        }
    }

    for ($i = 0; $i < $c0; $i++) {
        $res .='0';
        if ($n1) {
            $res .='1'; $n1--;
        }
        if ($n2) {
            $res .='1'; $n2--;
        }
    }

    if ($rest1) { $res .='1'; $rest1--; };
    if ($rest1) { $res .='1'; $rest1--; };
    return $res;
};

echo solve($c0, $c1, $res), "\n";

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
    assert_options(ASSERT_ACTIVE, 1);
    assert_options(ASSERT_BAIL, 1);
    $test = <<<INPUT
1000000 1000000
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);

$s = trim(fgets(MY_STDIN));
list($c0, $c1) = explode(' ', $s);

$solve = function($c0, $c1) {
    $n1 = $c0 - 1;
    $rest1 = $c1 - $n1;
    if ($rest1 < 0) {
        return array(-1);
    }

    $res = array();

    if ($n1 == 0) {
        $n2 = 0;
    } else if ($rest1 > $n1) {
        $n2 = $n1;
        $rest1 = $rest1 - $n1;
    } else {
        $n2 = $rest1;
        $rest1 = 0;
    }

    if ($rest1 > 4) {
        return array(-1);
    } else if ($rest1) {
        echo '1'; $rest1--;
        if ($rest1) {
            echo '1'; $rest1--;
        }
    }

    for ($i = 0; $i < $c0; $i++) {
        echo '0';
        if ($n1) {
            echo '1'; $n1--;
        }
        if ($n2) {
            echo '1'; $n2--;
        }
    }

    if ($rest1) { echo '1'; $rest1--; };
    if ($rest1) { echo '1'; $rest1--; };

    //return $res;
};

$res = $solve($c0, $c1);


ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occupied.ZS and Chris are good friends. They insist to get a pair of neighbouring empty seats. Two seats are considered neighbouring if they are in the same row and in the same pair. Given the configuration of the bus, can you help ZS and Chris determine where they should sit?

The first line of the input contains a single integer n (1 ≤ n ≤ 1000) — the number of rows of seats in the bus. Then, n lines follow. Each line contains exactly 5 characters, the first two of them denote the first pair of seats in the row, the third character denotes the walkway (it always equals '|') and the last two of them denote the second pair of seats in the row.  Each character, except the walkway, equals to 'O' or to 'X'. 'O' denotes an empty seat, 'X' denotes an occupied seat. See the sample cases for more details.

If it is possible for Chris and ZS to sit at neighbouring empty seats, print "YES" (without quotes) in the first line. In the next n lines print the bus configuration, where the characters in the pair of seats for Chris and ZS is changed with characters '+'. Thus the configuration should differ from the input one by exactly two charaters (they should be equal to 'O' in the input and to '+' in the output). If there is no pair of seats for Chris and ZS, print "NO" (without quotes) in a single line. If there are multiple solutions, you may print any of them.

NoteNote that the following is an incorrect configuration for the first sample case because the seats must be in the same pair.O+|+XXO|XXOX|OOXX|OXOO|OOOO|XX

<?php
function write($text){
	file_put_contents('php://stdout', $text);
}
function read(){
	return trim(fgets(STDIN));
}

$n = read();

$data = array();
$isset = false;

for($i=0; $i<$n; $i++){
	$str = read();
	$str = explode('|', $str);
	$data[$i] = $str;
	if($isset) continue;
	if(($str[0][0] == 'O') && ($str[0][1] == 'O')){
		$str[0][0] = '+';
		$str[0][1] = '+';
		$data[$i] = $str;
		$isset = true;
	}
	elseif(($str[1][0] == 'O') && ($str[1][1] == 'O')){
		$str[1][0] = '+';
		$str[1][1] = '+';
		$data[$i] = $str;
		$isset = true;
	}
}

if($isset){
	write('YES'."\r\n");
	foreach ($data as $str){
		write($str[0].'|'.$str[1]."\r\n");
	}
}
else
	write('NO');

<?php
$numofsets=trim(fgets(STDIN));
 $im=array();
for ($a=0; $a < $numofsets; $a++) {
    $ex[]=explode("|", trim(fgets(STDIN)));
}
for ($x=0; $x < $numofsets; $x++)
  if ($ex[$x][0] == "OO")  {
       $rep1[$x]=array(0 => "++", 1 => $ex[$x][1]);
      $replace=array_replace($ex, $rep1);
      $yes=1;
     break;
  }elseif ($ex[$x][1] == "OO") {
       $rep1[$x]=array(0 => $ex[$x][0], 1 => "++");
      $replace=array_replace($ex, $rep1);
      $yes=1;
      break;
   }
  for ($f=0; $f < $numofsets; $f++) {
 $im[]=implode("|", $replace[$f]);
  }
if ($yes == 1) {
    echo "YES".PHP_EOL;
  echo implode(PHP_EOL ,$im);
}else echo "NO";
?>

<?php
$n=fgets(STDIN);
$input=[];
for ($i=0; $i < $n ; $i++) {
      $input[]=trim(fgets(STDIN));
}
$a=0;
for ($i=0; $i < $n ; $i++) {
      $name=explode('|',$input[$i]);
      if($name[0] == 'OO'){
            $name[0]='++';
            $a=1;
            $input[$i]=join('|',$name);
            break;
      }else if($name[1] == 'OO'){
            $name[1]='++';
            $input[$i]=join('|',$name);
            $a=1;
            break;
      }
}
if ($a == 1) {
      echo "YES\n";
      foreach ($input as $key => $value) {
            echo $value."\n";
      }
}else{
      echo "NO";
}

<?php
fscanf(STDIN,"%d",$n);
for($i=0;$i<$n;$i++)
{
	$str=trim(fgets(STDIN));
	$cnvrtArr[$i]=explode('|', $str);
}
//print_r($cnvrtArr);
$flag=0;
for($i=0;$i<$n;$i++)
{
	for($j=0;$j<2;$j++)
	{
		if($cnvrtArr[$i][$j]=='OO')
		{
			//echo "YES\n";
			$cnvrtArr[$i][$j]='++';
			$flag=1;
			break;

		}

	}
	if($flag==1)
		break;

}
if($flag==1)
{
	echo "YES\n";
	for($i=0;$i<$n;$i++)
	{
	 for($j=0;$j<2;$j++)
	  {
	  	if($j==0)
			echo $cnvrtArr[$i][$j]."|";
         else
		echo $cnvrtArr[$i][$j];

		}
		echo "\n";
	}
}
if($flag==0)
	echo "NO";

<?php
 $kol_ryadov = fgets(STDIN);
 $YES_NO = 'NO';
 for($k = 1; $k<=$kol_ryadov; $k++){
 	$ryad[$k] = fgets(STDIN);
 	preg_match_all('#(.+)\|(.+)#', $ryad[$k] , $para );
 	if($YES_NO=='YES'){
 		$otvet[$k] = trim($ryad[$k]);
 		continue;
 	}
	 	if(trim($para[1][0])=='OO'){
	 		$YES_NO = 'YES';
	 		$otvet[$k]='++|'.trim($para[2][0]);
	 	}elseif(trim($para[2][0])=='OO') {
	 		$YES_NO = 'YES';
	 		$otvet[$k]=trim($para[1][0]).'|++';
	 	}else{
	 		$otvet[$k]=trim($ryad[$k]);
	 	}
 }
if($YES_NO=='YES'){
fwrite(STDOUT, "YES\n");
 for($i=1;$i<=count($otvet);$i++){
 	fwrite(STDOUT, trim($otvet[$i]) . "\n" );
 }
}else{
	fwrite(STDOUT, $YES_NO."\n");
}

<?php

$n = trim(fgets(STDIN));

$ans = "";

$notfound = true;

for($i = 0; $i<$n; $i++){
    $k = explode('|', trim(fgets(STDIN)));
    if($k[0] == "OO" && $notfound){
        $ans .= "++";
        $notfound = false;
    }else{
        $ans .= $k[0];
    }

    $ans .= "|";

    if($k[1] == "OO" && $notfound){
        $ans .= "++";
        $notfound = false;
    }else{
        $ans .= $k[1];
    }

    $ans .= "\n";
}

fwrite(STDOUT, ($notfound ? "NO" : "YES\n".trim($ans)));

?>

<?php

$stdin = fopen('php://stdin', 'r');
$cnt = trim(fgets($stdin));
$data = FALSE;
for ($i = 0; $i < $cnt; $i++) {
    $data[] = trim(fgets($stdin));
}
$result = FALSE;
for ($i = 0; $i < $cnt; $i++) {
    if ($data[$i][0] == "O" && $data[$i][1] == "O") {
        $data[$i][0] = $data[$i][1] = "+";
        $result = true;
        break;
    }
    if ($data[$i][3] == "O" && $data[$i][4] == "O") {
        $data[$i][3] = $data[$i][4] = "+";
        $result = true;
        break;
    }
}
if ($result == FALSE) {
    echo 'NO';
} else {
    echo "YES\n";
    for ($i = 0; $i < $cnt; $i++) {
        echo $data[$i] . "\n";
    }
}

<?php
    function check( $s )
    {
        if($s[0] == $s[1] && $s[0] == "O")
            return true;
        else return false;
    }

    fscanf(STDIN, "%d", $n);

    $arr = array();

    $flag = true;

    while($n)
    {
        $n-=1;
        fscanf(STDIN, "%s", $s);
        if( $flag )
        {
            $buffer = explode("|", $s);
            if( check($buffer[0]) )
            {
                $buffer[0] = "++";
                $flag = false;
            }
            else if( check($buffer[1]) )
            {
                $buffer[1] = "++";
                $flag = false;
            }
            $s = implode("|", $buffer);
        }
        array_push($arr, $s);
    }

    if($flag)
        echo "NO" . PHP_EOL;
    else
    {
        echo "YES" . PHP_EOL;
        foreach( $arr as $t )
            echo $t . PHP_EOL;
    }
?>

<?php
    function check( $s )
    {
        if($s[0] == $s[1] && $s[0] == "O")
            return true;
        else return false;
    }

    fscanf(STDIN, "%d", $n);

    $arr = array();

    $flag = true;

    while($n)
    {
        $n-=1;
        fscanf(STDIN, "%s", $s);
        if( $flag )
        {
            $buffer = explode("|", $s);
            if( check($buffer[0]) )
            {
                $buffer[0] = "++";
                $flag = false;
            }
            else if( check($buffer[1]) )
            {
                $buffer[1] = "++";
                $flag = false;
            }
            $s = implode("|", $buffer);
        }
        array_push($arr, $s);
    }

    foreach( $arr as $t )
        echo $t . PHP_EOL;

?>

<?php
    function check( $s )
    {
        if($s[0] == $s[1] && $s[0] == "O")
            return true;
        else return false;
    }

    fscanf(STDIN, "%d", $n);

    $arr = array();

    $flag = true;

    while($n)
    {
        $n-=1;
        fscanf(STDIN, "%s", $s);
        if( $flag )
        {
            $buffer = explode("|", $s);
            if( check($buffer[0]) )
            {
                $buffer[0] = "++";
                $flag = false;
            }
            else if( check($buffer[1]) )
            {
                $buffer[1] = "++";
                $flag = false;
            }
            $s = implode("|", $buffer);
        }
        array_push($arr, $s);
    }

    echo ($flag ? "NO" : "YES") . PHP_EOL;

    foreach( $arr as $t )
        echo $t . PHP_EOL;

?>

<?php
    function check( $s )
    {
        if($s[0] == $s[1] && $s[0] == "O")
            return true;
        else return false;
    }

    fscanf(STDIN, "%d", $n);

    $arr = array();

    $flag = true;

    while($n)
    {
        $n-=1;
        fscanf(STDIN, "%s", $s);
        if( $flag )
        {
            $buffer = explode("|", $s);
            if( check($buffer[0]) )
            {
                $buffer[0] = "++";
                $flag = false;
            }
            else if( check($buffer[1]) )
            {
                $buffer[1] = "++";
                $flag = false;
            }
            $s = implode("|", $buffer);
        }
        array_push($arr, $s);
    }

    if(flag)
        echo "NO" . PHP_EOL;
    else
    {
        echo "YES" . PHP_EOL;
        foreach( $arr as $t )
            echo $t . PHP_EOL;
    }
?>


You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.

The first line contains integer n (1 ≤ n ≤ 3·105) — the number of points on the line. The second line contains n integers xi ( - 109 ≤ xi ≤ 109) — the coordinates of the given n points.

Print the only integer x — the position of the optimal point on the line. If there are several optimal points print the position of the leftmost one. It is guaranteed that the answer is always the integer.

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = ceil($a / 2);
print $b[$c - 1];
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = ceil($a / 2);
print $c;
?>

<?php
$a = trim(fgets(STDIN));
$b = explode(" ", trim(fgets(STDIN)));
$c = ceil($a / 2);
$d = ceil(array_sum($b) / $a);
$e = array();
$f = array();
for($x = 0; $x < $a; $x++)
{
     if($b[$x] <= $d)
     {
          $e[$x] = $b[$x];
          if(count($e) == $c)
          {
               break;
          }
     }
     else
     {
          $f[$x] = $b[$x];
     }
}
if(count($e) >= $c)
{
     sort($e);
     print $e[$c - 1];
}
else
{
     sort($f);
     print $f[$c - count($e) - 1];
}
?>


A sequence of $$$n$$$ integers is called a permutation if it contains all integers from $$$1$$$ to $$$n$$$ exactly once.Given two integers $$$n$$$ and $$$k$$$, construct a permutation $$$a$$$ of numbers from $$$1$$$ to $$$n$$$ which has exactly $$$k$$$ peaks. An index $$$i$$$ of an array $$$a$$$ of size $$$n$$$ is said to be a peak if $$$1 < i < n$$$ and $$$a_i \gt a_{i-1}$$$ and $$$a_i \gt a_{i+1}$$$. If such permutation is not possible, then print $$$-1$$$.

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. Then $$$t$$$ lines follow, each containing two space-separated integers $$$n$$$ ($$$1 \leq n \leq 100$$$) and $$$k$$$ ($$$0 \leq k \leq n$$$) — the length of an array and the required number of peaks.

Output $$$t$$$ lines. For each test case, if there is no permutation with given length and number of peaks, then print $$$-1$$$. Otherwise print a line containing $$$n$$$ space-separated integers which forms a permutation of numbers from $$$1$$$ to $$$n$$$ and contains exactly $$$k$$$ peaks.  If there are multiple answers, print any.

NoteIn the second test case of the example, we have array $$$a = [2,4,1,5,3]$$$. Here, indices $$$i=2$$$ and $$$i=4$$$ are the peaks of the array. This is because $$$(a_{2} \gt a_{1} $$$, $$$a_{2} \gt a_{3})$$$ and $$$(a_{4} \gt a_{3}$$$, $$$a_{4} \gt a_{5})$$$.