<?
$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));
$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
    $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', $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

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";

<?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
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
	$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

$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

$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
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
    $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

$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

$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;
        }
    }
?>


<?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);


<?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);


<?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 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
    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;
    }
?>


<?php

$flag = 1; //must be not zero for STDIN
$in = 'php://stdin';
if (!$flag)
{
    $in = "input.txt";
}
$fd = fopen($in, "r");
fscanf($fd, "%d\n", $n);
$data = fgets($fd);
$score = explode(" ", $data);
fclose($fd);

for ($c = 0; $c < $n; $c++)
{
    $score[$c] = intval($score[$c]);
}
$result = 0;
$min = $score[0];
$max = $score[0];
for ($c = 1; $c < $n; $c++)
{
    if ($score[$c] < $min)
    {
        $min = $score[$c];
        $result++;
    }
    if ($score[$c] > $max)
    {
        $max = $score[$c];
        $result++;
    }
}
printf("$result\n");
?>

<?php
$n = trim(fgets(STDIN));
$mas = explode(' ', trim(fgets(STDIN)));
$nice = 0;
$max = $mas[0];
$min = $mas[0];
for($i=0; $i<$n; $i++) {
	if($mas[$i]>$max) {
		$nice++;
		$max = $mas[$i];
	}
	if($mas[$i] < $min) {
		$nice++;
		$min = $mas[$i];
	}
}
echo $nice;

<?php
$n = trim(fgets(STDIN));
$results = explode(" ",trim(fgets(STDIN)));
$max = $results[0];
$GG=0;
$min = $results[0];
for ($i = 1;$i<$n;$i++)
{
    if ($results[$i]>$max)
    {
        $max = $results[$i];
        $GG++;
    }
    elseif ($results[$i]<$min)
    {
        $min = $results[$i];
        $GG++;
    }
}
echo $GG;

<?
error_reporting(0);

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

$min = $points[0];
$max = $points[0];
$countTrue = 0;
for( $i = 1; $i < $count; $i++ ){
	if( $points[$i] > $max){
		$max = $points[$i];
		$countTrue++;
	}
	if( $points[$i] < $min){
		$min = $points[$i];
		$countTrue++;
	}
}
echo $countTrue;
fclose($fp);
?>

<?php
fscanf(STDIN,"%d",$n);
$line=trim(fgets(STDIN));
$arr=explode(" ",$line);
$count=0;
$max=$arr[0];
$min=$arr[0];
for($i=0;$i<count($arr);$i++)
    {
    	if($arr[$i]>$max){
    		$max=$arr[$i];
    		$count++;
    	}
    	elseif ($arr[$i]<$min) {
    		$min=$arr[$i];
    		$count++;
    	}
    }
    echo "$count";

//echo $count;

<?php

$n = readline();
$stroka = readline();
$stroka = explode(' ', $stroka);
$shock = 0;
$sravnenie_plus = $stroka[0];
$sravnenie_minus = $stroka[0];
foreach ($stroka as $v) {
    if ($v > $sravnenie_plus) {
        $shock += 1;
        $sravnenie_plus = $v;
    }
    if ($v < $sravnenie_minus) {
        $shock += 1;
        $sravnenie_minus = $v;
    }
}

echo $shock;

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

$mas = explode(' ', trim(fgets(STDIN)));
$k = 0;
for ($i = 1; $i < count($mas); $i++)
{
    if ($mas[$i] > max(array_slice($mas, 0, $i)) || $mas[$i] < min(array_slice($mas, 0, $i)))
        $k++;
}
echo $k;

?>

<?php
// 155A     I_love_\%username\%
$in = fopen("php://stdin", 'r');

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

$input_line = fgets($in);
$arr = preg_split('/ /', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);

$min = $max = $arr[0];
$out = 0;

foreach ($arr as $key => $value) {
    if ($min > (int) $value) {
        $min = $value;
        $out ++;
    }

    if ($max < (int) $value) {
        $max = $value;
        $out ++;
    }
}

echo $out;

?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$arr = explode("\n", $n);
$numbers = explode(" ", $arr[1]);
$min = (int) $numbers[0];
$max = (int) $numbers[0];
$count = 0;
for($i = 1; $i < $arr[0]; $i++){
    $temp = (int) $numbers[$i];
    if($temp < $min){
        $min = $temp;
        $count++;
    } else if($temp > $max){
        $max = $temp;
        $count++;
    }
}
echo $count;

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

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

$numbers=explode(" ", trim($lines[1]));
$res=0;
$min=$numbers[0]; $max=$numbers[0];
for ($i=1; $i<count($numbers); $i++)
{
    $cur=$numbers[$i];
    if ($cur>$max) { $max=$cur; $res++;}
    if ($cur<$min) { $min=$cur; $res++;}
}
echo $res;
?>

<?php
    $fp = fopen('php://stdin', 'r');
    $n = rtrim(fgets($fp));
    $results = explode(' ', rtrim(fgets($fp)));
    $amazing = 0;
    $min = $max = $results[0];
    for($i = 1; $i < $n; $i++) {
        if($results[$i] > $max) {
            $max = $results[$i];
            $amazing++;
        }elseif($results[$i] < $min) {
            $min = $results[$i];
            $amazing++;
        }
    }
    echo $amazing;
?>

<?php

function solve(){
	$Token = new Token(rtrim(fgets(STDIN)), " ");
	$inp_n = $Token->nextInt();
	$Token = new Token(rtrim(fgets(STDIN)), " ");
	$inp_arr = $Token->nextIntArray();

	$temp_max = $inp_arr[0];
	$temp_min = $inp_arr[0];
	$temp_c = 0;
	$AMAIZING = 0;
	foreach ($inp_arr as $as_i) {
		$temp_c++;
		if ($temp_c == 1) continue;

		if ($temp_max < $as_i) {
			$temp_max = $as_i;
			$AMAIZING++;
		} elseif ($temp_min > $as_i) {
			$temp_min = $as_i;
			$AMAIZING++;
		}
	}

	printf("%d", $AMAIZING);

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $_

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;
	}
}
*/
}

/*
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("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

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

<?php

$count = fgets(STDIN);
$exhibitions = explode(" ", fgets(STDIN));
$local_min = $exhibitions[0];
$local_max = $exhibitions[0];
$magix = 0;
for ($i=1;$i<count($exhibitions); $i++) {
        $e=(int)$exhibitions[$i];
                if ($e < $local_min) {
                        $local_min = $e;
                        $magix++;
                }
                if ($e > $local_max) {
                        $local_max = $e;
                        $magix++;
                }
}
fputs(STDOUT, $magix);

<?php

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

$numbers = explode(' ', $file[1], trim($file[0]));

$result = 0;

$min = (int) $numbers[0];
$max = (int) $numbers[0];

foreach ($numbers as $number) {
	$number = (int) $number;
	if ($number < $min) {
		$min = $number;
		$result++;
	} else if ($number > $max) {
		$max = $number;
		$result++;
	}
}

echo $result . PHP_EOL;

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

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

$numbers = explode(' ', $line);

foreach ($numbers as $key => $value) {
    $numbers[$key] = intval($value);
}

$counter = 0;
$array = array();

for($i=0; $i<count($numbers); $i++) {
    if(in_array($numbers[$i], $array)) continue;

    $array[] = $numbers[$i];
    if(((max($array) == $numbers[$i]) || (min($array) == $numbers[$i])) && count($array) !== 1 ) {
        $counter++;
    }
}

echo $counter;

<?php
error_reporting("off");
//155A: I_love_%username%
$n = trim(fgets(STDIN)); //$n = 10;
$scores = explode(" ", trim(fgets(STDIN))); //$scores = explode(" ", "4664 6496 5814 7010 5762 5736 6944 4850 3698 7242");
$recordhigh = 0;
$recordlow = 0;
$amazing = 0;
foreach ($scores as $key => $value) {
    if ($key == 0) {
        $recordhigh = $value;
        $recordlow = $value;
    }
    if ($value > $recordhigh) {
        $recordhigh = $value;
        $amazing++;
    }
    if ($value < $recordlow) {
        $recordlow = $value;
        $amazing++;
    }
}
echo $amazing;
?>

<?php

function solve(){
	$Token = new Token(rtrim(fgets(STDIN)), " ");
	$inp_n = $Token->nextInt();
	$Token = new Token(rtrim(fgets(STDIN)), " ");
	$inp_arr = $Token->nextIntArray();

	$temp_max = $inp_arr[1];
	$temp_min = $inp_arr[1];
	$temp_c = 0;
	$AMAIZING = 0;
	foreach ($inp_arr as $as_i) {
		$temp_c++;
		if ($temp_c == 1) continue;

		if ($temp_max < $as_i) {
			$temp_max = $as_i;
			$AMAIZING++;
		} elseif ($temp_min > $as_i) {
			$temp_min = $as_i;
			$AMAIZING++;
		}
	}

	printf("%d", $AMAIZING);

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $_

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;
	}
}
*/
}

/*
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("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

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

<?php

$flag = 1; //must be not zero for STDIN
$in = 'php://stdin';
if (!$flag)
{
    $in = "input.txt";
}
$fd = fopen($in, "r");
fscanf($fd, "%d\n", $n);
$data = fgets($fd);
$score = explode(" ", $data);
fclose($fd);

for ($c=0;$c<$n;$c++)
{
   $score[$c]=  intval($score[$c]);
}
$result=0 ;
$min=$score[0]; $max=$score[0];
for ($c=1 ;$c<$n;$c++)
{
    if ($score[$c]<$min)
    {
        $min=$score[$c];
        $result++;
    }
    if ($score[$c]>$max)
    {
        $max=$score[$c];
        $result++;
    }
    printf ( "min=%d max=%d score=%d\n" ,$min, $max, $score[$c]);
}
printf ("$result\n");
?>

<?php

$flag = 1; //must be not zero for STDIN
$in = 'php://stdin';
if (!$flag)
{
    $in = "input.txt";
}
$fd = fopen($in, "r");
fscanf($fd, "%d\n", $n);
$data = fgets($fd);
$score = explode(" ", $data);
fclose($fd);

for ($c=0;$c<$n;$c++)
{
   $score[$c]=  intval($score[$c]);
}
$result=0 ;
$min=0; $max=0;
for ($c=0 ;$c<$n;$c++)
{
    if ($score[$c]<$min)
    {
        $min=$score[$c];
        $result++;
    }
    if ($score[$c]>$max)
    {
        $max=$score[$c];
        $result++;
    }
}
printf ("$result\n");
?>

<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $min);
$max = $min;
$a = 0;
for ($i=0;$i<$n-1;$i++){
	fscanf(STDIN, "%d", $curr);
	if ($curr < $min){
		$a++;
		$min = $curr;
	}
	else if ($curr > $max){
		$a++;
		$max = $curr;
	}
}
echo $a;
?>

<?php
fscanf(STDIN, "%d %d", $n, $min);
$max = $min;
$a = 0;
for ($i=0;$i<$n-1;$i++){
	fscanf(STDIN, "%d", $curr);
	if ($curr < $min){
		$a++;
		$min = $curr;
	}
	else if ($curr > $max){
		$a++;
		$max = $curr;
	}
}
echo $a;
?>

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$arr = explode("\n", $n);
$numbers = explode(" ", $arr[1]);
$min = (int) $numbers[0];
$max = (int) $numbers[0];
$count = 0;
echo $numbers[0].'\n';
for($i = 1; $i < $arr[0]; $i++){
    $temp = (int) $numbers[$i];
    if($temp < $min){
        $min = $temp;
        $count++;
    } else if($temp > $max){
        $max = $temp;
        $count++;
    }
    echo $temp.'\n';
}
echo $count;

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$arr = explode("\n", $n);
$numbers = explode(" ", $arr[1]);
$num = $numbers[0];
$min = $num;
$max = $num;
$count = 0;
for($i = 1; $i < $arr[0]; $i++){
    if($numbers[$i] < $min || $numbers[$i] > $max){
        $count++;
    }
}
echo $count;

<?php
$s = fopen("php://stdin", 'r');
$n = stream_get_contents($s);
$arr = explode("\n", $n);
$numbers = explode(" ", $arr[1]);
$num = $numbers[0];
$min = $num;
$max = $num;
$count = 0;
for($i = 1; $i < $arr[0]; $i++){
    $temp =  $numbers[$i];
    if($temp < $min){
        $min = $temp;
        $count++;
    }
    if($temp > $max){
        $max = $temp;
        $count++;
    }
}
echo $count;

<?php
$count = fgets(STDIN);
$exhibitions = explode(" ", fgets(STDIN), "\n");
$local_min = $exhibitions[0];
$local_max = $exhibitions[0];
$magix = 0;
for ($i = 1; $i < count($exhibitions); $i++) {
        $e = (int) $exhibitions[$i];
        if ($e != "") {
                if ($e < $local_min) {
                        $local_min = $e;
                        $magix++;
                }
                if ($e > $local_max) {
                        $local_max = $e;
                        $magix++;
                }
        }
}
fputs(STDOUT, $magix);

<?php

$count = fgets(STDIN);
$exhibitions = explode(" ", fgets(STDIN));
$local_min = $exhibitions[0];
$local_max = $exhibitions[0];
$magix = 0;
for ($i = 1; $i < count($exhibitions); $i++) {
        $e = (int) $exhibitions[$i];
        if ($e != "") {
                if ($e < $local_min) {
                        $local_min = $e;
                        $magix++;
                }
                if ($e > $local_max) {
                        $local_max = $e;
                        $magix++;
                }
        }
}
fputs(STDOUT, $magix);

<?php

$count = fgets(STDIN);
$exhibitions = explode(" ", trim(fgets(STDIN),"\n"));
$local_min = $exhibitions[0];
$local_max = $exhibitions[0];
$magix = 0;
for ($i=1;$i<count($exhibitions); $i++) {
        $e=$exhibitions[$i];
        if ($e!="") {
                if ($e < $local_min) {
                        $local_min = $e;
                        $magix++;
                }
                if ($e > $local_max) {
                        $local_max = $e;
                        $magix++;
                }
        }
}
print $magix;

<?php

$count = fgets(STDIN);
$exhibitions = explode(" ", fgets(STDIN),"\n");
$local_min = $exhibitions[0];
$local_max = $exhibitions[0];
$magix = 0;
for ($i=1;$i<count($exhibitions); $i++) {
        $e=(int)$exhibitions[$i];
        if ($e!="") {
                if ($e < $local_min) {
                        $local_min = $e;
                        $magix++;
                }
                if ($e > $local_max) {
                        $local_max = $e;
                        $magix++;
                }
        }
}
print $magix;


<?php
// 462A     Яблов и простая задача

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

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

$arr = array();

for ($i=0; $i < $n; $i++) {
    $input_line = fgets($in);
    $arr[$i] = preg_split('//', substr($input_line, 0, strlen($input_line)-2), -1, PREG_SPLIT_NO_EMPTY);
}

for ($i=0; $i < $n; $i++) {
    for ($j=0; $j < $n; $j++) {

        $count_o = 0;
        if ($arr[$i-1][$j] === 'o') $count_o ++;
        if ($arr[$i+1][$j] === 'o') $count_o ++;
        if ($arr[$i][$j-1] === 'o') $count_o ++;
        if ($arr[$i][$j+1] === 'o') $count_o ++;

        if (($count_o % 2) != 0) {
            echo "NO";
            exit();
        }
    }
}

echo "YES";

?>


<?php

//fscanf(STDIN, "%d", $t);
$values = array_map('intval', explode(' ',trim(fgets(STDIN))));
$n = $values[0];
$k = $values[1];

$ppl = $values = array_map('intval', explode(' ',trim(fgets(STDIN))));
rsort($ppl);
$res = 0;
$last = 0;
for ($i = 1 ; $i <= count($ppl); $i++) {
	if ($i%$k == 0 || $i == count($ppl)) {
		$res += $ppl[$last]*2 - 2;
		$last = $i;
	}
}

echo $res."\n";

<?php

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

list($n, $k) = explode(" ",trim(fgets($in)));

$a = explode(" ",trim(fgets($in)));

rsort($a);

$i = 0;
$s = 0;
while($i<$n){
	$s += ($a[$i]-1)*2;
	$i += $k;
}

echo "$s\n";

<?php
list($n, $k) = explode(" ",trim(fgets(STDIN)));
$arr = explode(" ",trim(fgets(STDIN)));
sort($arr);
$ans = 0;
for ($i=$n-1; $i>=0; $i-=$k) {
    $ans += 2*($arr[$i]-1);
}
echo $ans;
?>

<?php
list($n, $k) = explode(" ",trim(fgets(STDIN)));
$f = explode(" ",trim(fgets(STDIN)));
sort($f);
for($i=$n-1;$i>=0;$i-=$k){
	$ans+=2*($f[$i]-1);
}
echo $ans;
?>

<?php

//fscanf(STDIN, "%d", $t);
$values = array_map('intval', explode(' ',trim(fgets(STDIN))));
$n = $values[0];
$k = $values[1];

$ppl = $values = array_map('intval', explode(' ',trim(fgets(STDIN))));
rsort($ppl);
$res = 0;

for ($i = 1 ; $i <= count($ppl); $i++) {
	if ($i%$k == 0 || $i == count($ppl)) {
		$res += $ppl[$i-1]*2 - 2;
	}
}

echo $res."\n";