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

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

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

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

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Excute algorithm
rl.on('close', () => {

    const numOfCoins = inputs[1].split(' ').length;
    const coinsValue = inputs[1].split(' ').sort((a, b) => b - a);
    const totalValue = inputs[1].split(' ').reduce((accum, c) => accum += parseInt(c), 0)
    const minVal = (totalValue / 2) + 1;
    let minNumOfCoins = 0;
    let myValue = 0;

    for (let i = 0; i < numOfCoins; i++) {

        if (myValue < Math.floor(minVal)) {
            myValue += parseInt(coinsValue[i])
            minNumOfCoins++
        } else {
            return console.log(minNumOfCoins)
        }
    }

    return console.log(minNumOfCoins)

})

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  const n = +readline();
  const p = readline().split(' ').map(x => parseInt(x));
  const half = p.reduce((l, m) => l + m, 0) / 2;
  let s = 0;
  let c = 0;
  p.sort((l, m) => m - l);
  while (s <= half) {
    s += p[c++];
    if (s > half) {
      break;
    }
  }
  print(c);
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => b - a);

  const sum = arr.reduce((a, b) => a + b, 0);
  let currSum = 0;
  let idx = 0;

  while (currSum <= Math.floor(sum / 2)) {
    currSum += arr[idx];
    idx++;
  }

  console.log(idx);

  c++;
});

const readLine = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout,
});
const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const arr = input[1].split(' ').map(x => parseInt(x));

  let sum = arr.reduce((prev, next) => prev+next, 0);
  let yourSum = 0;

  arr.sort((a, b) => a - b);
  for (let i = arr.length-1; i >= 0; i -= 1) {
    yourSum += arr[i]; sum -= arr[i];
    if (yourSum > sum) {
      console.log(arr.length - i); break;
    }
  }
});

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// thats all what you have to write to get input from stdin, using readLine.

// Main code runs in main();

function main(){

    let coinCount =Number.parseInt( readline());
    let coins = readline().split(" ").map( (item) => Number.parseInt(item));
    // desc
    coins = coins.sort((a,b) =>  a - b);

    let picked = [];
    let notPicked = coins;
    while(true) {

         picked.push(notPicked.pop());
         let pickedSum =  picked.reduce((a , b) => a + b, 0)
         let notPickedSum = notPicked.reduce((a,b) => a + b, 0);
         if(pickedSum > notPickedSum)
         {
            process.stdout.write(picked.length.toString());
             break;
         }

    }

}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let standardInputString = '';
let currentLine = 0;

function readLine() {
    return standardInputString[currentLine++];
}

process.stdin.on('data', rawData=> {
    standardInputString += rawData;
})

process.stdin.on('end', _ => {
    standardInputString = standardInputString.trim().split('\n').map(line=> {
        return line.trim();
    })
    main();
})

function main() {
    const coinsNumber = +(readLine());
    const coin = readLine().split(" ").join(",");
    let sum = eval(coin.split(",").join("+"));
    const minimum = sum / 2;
    let possible = 0;
    let count = 0;
    let sorted = Array.from(coin.split(",")).map(x=> 1*x);
    sorted = sorted.sort((a,b)=> a - b);
    for(let i = sorted.length - 1; i >= 0; i--) {
        possible = possible + (1* sorted[i]);
        count++;
        if(possible > minimum) break;
    }
    console.log(count);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let numberofCoins = parseInt(readLine());
    let valuesofCoins = readLine().split(' ').map(Number);
    let sum = 0;
    for (let i = 0; i < valuesofCoins.length; i++) {
        sum = sum + valuesofCoins[i];
    }

    valuesofCoins = valuesofCoins.sort((a, b) => b - a);
    let finalArry = [];
    let finalSum = 0;
    for (let i = 0; i < valuesofCoins.length; i++) {
        if (finalSum <= sum / 2) {
            finalArry.push(valuesofCoins[i]);
            finalSum = finalSum + valuesofCoins[i];
        }
    }
    let final = finalArry.length;
    console.log(final);
}

let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});
for (let i = 1; i < txt.length; i += 2) {
    let info = txt[i].split(" ").filter(data => {
        return data.length > 0;
    }).map(data => {
        return data * 1;
    }).sort((a, b) => {
        return b - a;
    });
    doit(info);
}

function doit(tab) {
    let me=0,twin=0,coins=0;
    tab.forEach(data=>{
        twin+=data;
    });
    tab.forEach(data=>{
        if(me>twin){
            return;
        }else{
            me+=data;
            twin-=data;
            ++coins;
        }
    });
    console.log(coins);
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdin = '';

process.stdin.on('data', (input) => {
  stdin += input;
});

process.stdin.on('end', () => {
  const data = stdin.split('\n');
  let totalSum = 0;

  const coins = stdin
    .split('\n')[1]
    .split(' ')
    .map((coin) => {
      const num = Number(coin);
      totalSum += num;
      return num;
    })
    .sort((a, b) => a - b);

  let forBro = 0;
  let forBroCount = 0;

  for (const coin of coins) {
    forBro += coin;
    if (forBro < totalSum / 2) forBroCount++;
    else break;
  }

  process.stdout.write(String(coins.length - forBroCount));
});

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let stdin = '';

process.stdin.on('data', (input) => {
  stdin += input;
});

process.stdin.on('end', () => {
  const data = stdin.split('\n');
  const len = Number(data[0]);
  let totalSum = 0;

  const coins = data[1]
    .split(' ')
    .map((coin) => {
      const num = Number(coin);
      totalSum += num;
      return num;
    })
    .sort((a, b) => a - b);

  let forBro = 0;
  let forBroCount = 0;

  for (const coin of coins) {
    forBro += coin;
    if (forBro < totalSum / 2) forBroCount++;
    else break;
  }

  process.stdout.write(String(len - forBroCount));
});

var  number=readline();
var  coins=readline();
var array = coins.split(" ").map(Number);
array.sort(function(a, b){return a - b});
var sumCoins=0;
var result=0;
for( i=0;i<number;i++) {
sumCoins=sumCoins+array[i];
}
function getResult() {
for( i=0;i<number;i++) {
var sumI=0;
  for( k=0;k<i;k++) {
	sumI=sumI+array[k];
}
if(sumI>=sumCoins-sumI) {
	result=number-i+1
  return result
}

}
result=1;
return result
}

print(getResult())

function main(){
    var n = +readline();
    var ms = readline().split(' ').sort((a,b) => +b - +a);
    var sum = ms.reduce((acc, ac) => acc + +ac, 0);
    var med = sum / 2;
    var res = 0;
    for(var i = 0; i < n; ++i){
        res += +ms[i];
        if(res > med){
            break;
        }
    }
    print(i + 1);
}

main();

var r = +readline();
var w = readline().split(' ').map(function(v){return +v;}).sort(function(a, b){return b-a;});
var sum = w.reduce(function(a, b){return a+b;}, 0);
var c=0;
for(var i=0; c<=sum; i++){
    c+=w[i];
    sum-=w[i];
}
print(i);

readline();
var nums = readNums();
nums.sort((a,b) => b - a);
var need = nums.reduce((a,b) => a+b) / 2;
var value = 0;
for (var i = 0; i < nums.length && value <= need; i++) {
    value += nums[i];
}
print(i);

function readNums() {
    return readline().split(' ').map(v => v - 0);
}

n = parseInt(readline());
A = readline().split(" ");
A.sort(function(a,b){return parseInt(a) - parseInt(b)});
sum = 0;
sum1 = 0;
ats = 0;
for (var i = 0; i < n; i++){
    sum += parseInt(A[i]);
}
for (var i = n-1; i >= 0 && sum >= sum1; i--){
    sum -= parseInt(A[i]);
    sum1 += parseInt(A[i]);
    ats++;
}
write(ats);

var ints = function() {
	return readline().split(' ').map(function(word) {
		return parseInt(word)
	})
}

var asc = function(a, b) {
	return a - b
}

readline()
var numbers = ints(),
	sum = numbers.reduce(function(a, b) { return a + b }, 0),
	current = 0,
	counter = 0,
	index = numbers.length - 1

numbers.sort(asc)

while (index >= 0) {
	current += numbers[index]
	counter ++
	if (current > sum / 2)
		break
	index --
}

print(counter)

var numberOfCoins = Number(readline())
var coins = readline().split(' ').map(Number).sort((a, b) => a - b)

var total = 0
for(var i = 0; i < numberOfCoins; i++) {
  total += coins[i]
}

var numberOfCoinsPicked = 0
var valueCoinsPickes = 0

for(var i = numberOfCoins - 1; i >= 0; i--) {
  if (total >= valueCoinsPickes) {
    valueCoinsPickes += coins[i]
    total -= coins[i]
    numberOfCoinsPicked += 1
  }
}

print(numberOfCoinsPicked)

var len = readline();
var s = readline();
var sumRemain = 0;
var sumTake = 0;

var a = s
  .split(' ')
  .map(Number)
  .sort(function(a, b) {
    return b - a;
  });

a.forEach(function(b) {
  sumRemain += b;
});

for (var i = 0; i < len; i++) {
  sumTake += a[i];
  sumRemain -= a[i];
  if (sumTake > sumRemain) {
    print(i + 1);
    break;
  }
}

var quantity = readline();
var digits = readline().split(" ").sort((a, b) => a - b);

function sum(arr) {
	return arr.reduce((sum, item) => sum += +item, 0);
}

digits.reduceRight((result) => {
	if (result <= sum(digits)) {
		result += +digits.pop();
	}

	return result;
}, 0);

print(quantity - digits.length);

var main;

main = function() {
  var a, a1, a2, coins, i, mm, mycoin, num=0, _i, _ref;
  a1 = readline();
  a2 = Number(a1);
  coins = Array();
  a = readline().split(" ");
  for (i = _i = 0, _ref = a2 - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
    coins.push(Number(a[i]));
    num = num + Number(a[i]);

  }
  coins.sort(function(x, y) {
    return y - x;
  });
  mycoin = coins[0];

  mm = 0;
  while (Number(mycoin) <= num - mycoin) {
    mm++;
    mycoin = mycoin + coins[mm];
  }
  print(mm+1);

};

main();

;(function () {

	readline();
	var s = readline().split(' ').map(function (x) {return parseInt(x); }).sort(function (a, b) {return a - b;});

	var sum1 = 0;
	var sum2 = 0;

	var i = 0;
	var j = s.length - 1;

	while (j >= i)
		if ((sum1 + s[i]) >= sum2) sum2 += s[j--];
		else sum1 += s[i++];

	print(s.length - i);

}).call(this);

readline();
var arr = readline().split(" ").map(v => v - 0);
arr.sort((a,b) => b - a);
var s1 = arr.reduce((a, b) => a + b) / 2;
var s2 = 0;
for (var i = 0; i < arr.length && s2 <= s1; ++i) {
    s2 += arr[i];
}
print(i);

      var n = parseInt(readline());
      var line2 = readline()
          .split(" ")
          .map((el) => parseInt(el)),
        max = 0,
        sum = 0,
        counter = 0,
        equal = 0,
        currentsum = 0,
        myarr = [...line2];

      function findMax() {
        for (var i = 0; i < n; i++) {
          if (max < myarr[i]) {
            max = myarr[i];
          }
          sum += myarr[i];
        }
        return sum;
      }

      // each person money
      equal = findMax() / 2;
      // removing the current max from the array
      function spliceArray(max) {
        for (var j = 0; j < n; j++) {
          if (max == myarr[j]) {
            myarr.splice(j, 1);
            j = 0;
            break;
          }
        }
        return myarr;
      }

      for (var a = 0; a < n; a++) {
        if (max > equal) {
          counter++;
          break;
        }
        if (currentsum <= equal) {
          currentsum += max;
          spliceArray(max);
          counter++;
        }
        // searching for the next max
        max = 0;
        for (var x = 0; x < n; x++) {
          if (max < myarr[x]) {
            max = myarr[x];
          }
        }
      }

      print(counter);

      var n = parseInt(readline());
      var line2 = readline()
          .split(" ")
          .map((el) => parseInt(el)),
        max = 0,
        sum = 0,
        counter = 0,
        equal = 0,
        currentsum = 0,
        myarr = [...line2];

      function findMax() {
        for (var i = 0; i < n; i++) {
          if (max < myarr[i]) {
            max = myarr[i];
          }
          sum += myarr[i];
        }
        return sum;
      }

      equal = findMax() / 2;
      function spliceArray(max) {
        for (var j = 0; j < n; j++) {
          if (max == myarr[j]) {
            myarr.splice(j, 1);
            j = 0;
            break;
          }
        }
        return myarr;
      }

      for (var a = 0; a < n; a++) {
        if (max > equal) {
          counter++;
          break;
        }
        if (currentsum <= equal) {
          currentsum += max;
          spliceArray(max);
          counter++;
        }
        // searching for the next max
        max = 0;
        for (var x = 0; x < n; x++) {
          if (max < myarr[x]) {
            max = myarr[x];
          }
        }
      }

      print(counter);

      var n = parseInt(readline());
      var line2 = readline()
          .split(" ")
          .map((el) => parseInt(el)),
        max = 0,
        sum = 0,
        counter = 0,
        equal = 0,
        currentsum = 0,
        myarr = [...line2];

      function findMax() {
        for (var i = 0; i < n; i++) {
          if (max < myarr[i]) {
            max = myarr[i];
          }
          sum += myarr[i];
        }
        return sum;
      }

      equal = findMax() / 2;
      function spliceArray(max) {
        for (var j = 0; j < n; j++) {
          if (max == myarr[j]) {
            myarr.splice(j, 1);
            j = 0;
            break;
          }
        }
        return myarr;
      }

      for (var a = 0; a < n; a++) {
        if (max > equal) {
          counter++;
          break;
        }
        if (currentsum <= equal) {
          currentsum += max;
          spliceArray(max);
          counter++;
        }
        max = 0;
        for (var x = 0; x < n; x++) {
          if (max < myarr[x]) {
            max = myarr[x];
          }
        }
      }

      print(counter);

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort((a,b)=> a-b),
    sum = 0;
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
var counter=coins[numberOfCoin-1];
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= (sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);
        break;
    }
}

  var numberOfCoins = readline()
  var result = 0

  var coinsArr = readline().split(' ').map(function (coin) { return parseInt(coin, 10) })
  var sortedCoins = coinsArr.sort(function (a, b) {
    return b - a
  })

  for (var i = 0; i <= numberOfCoins; i++) {
    var arr1 = sortedCoins.slice(0, i)
    var arr2 = sortedCoins.slice(i)

    var sum1 = arr1.reduce(function (previous, current) {
      previous += current
      return previous
    }, 0)
    var sum2 = arr2.reduce(function (previous, current) {
      previous += current
      return previous
    }, 0)

    if (sum1 > sum2) {
      result = i
      break
    }
  }

  print(result)

// var print = this.print || require("lol-io").print;
// var write = this.write || require("lol-io").write;
// var readline = this.readline || require("lol-io").readline;
var n = readline();
var a = readline()
  .split(" ")
  .map((a) => parseInt(a));
var sum = a.reduce((x, y) => x + y, 0);
var x = Math.floor(sum / 2);
var final_sum = 0;
var count = 0;
var new_arr = a.sort((t, b) =>{
    return t - b;
  });
for (var i=n-1;i>=0;i--) {
  final_sum += new_arr[i];
  count++;
  if (final_sum > x) {
    print(count);
    break;
  }
}

var n=readline(); n=parseInt(n);
var arr=readline().split(' ').map(function(x){return  parseInt(x)  ; });
arr.sort(function(a,b){return a-b;}); var sum=0;
for( var i=0; i <n;i++)
{
    sum+=arr[i];
} var num=0;
for(var i=n-1;i>=0;i--)
{
    num+=arr[i]; if(num>sum/2){print(n-i); break;}
}

var n = readline();
var a = readline().split(' ').map(function(c){ return parseInt(c); }).sort(function(a, b){
	return b - a;
});
var totalsum = a.reduce(function(a, b){
	return a + b;
});
var mysum = 0;
var coinstaken = 0;

while((mysum <= (totalsum - mysum)) && (a.length > 0))
{
	mysum += a[0];
	coinstaken += 1;
	a.shift();
}

print(coinstaken);

'use strict';
let _ = readline(),
    totalAmount = 0,
    outAmount = 0,
    array = readline().split(' ').map(function(value){
        value = parseInt(value);
        totalAmount += value
        return value;
    }).sort(function(a, b){return a - b}).reverse();

let i = 0;
for(; totalAmount >= outAmount; i++){
    totalAmount -= array[i];
    outAmount += array[i];
}

write(i)

var n  = +readline();

var arr = readline().split(' ');

for(var i in arr)
	arr[i] = +arr[i];

function sort_inc(a,b){
	return a - b;
}

arr.sort(sort_inc);

var sum = 0;
var ans = +n;
var fsum = 0;

for(var i in arr)
	sum += arr[i];

for(var i in arr){

	fsum += arr[i];
	sum -= arr[i];

	if(fsum >= sum){
		sum = n - i;
		break;
	}

}

print(sum);

var coinNum = parseInt(readline());
var coins = readline().split(' ').map(function(numStr){
    return parseInt(numStr);
}).sort(function(a, b){
    return b - a;
});
var i, totalSum = 0, halfTotalSum, partSum = 0, need = 0;

coins.forEach(function(num){
    totalSum += num;
});

halfTotalSum = Math.floor(totalSum / 2);

for(i=0;i<coins.length;i++){
    partSum += coins[i];
    need ++;
    if(partSum > halfTotalSum){
        break;
    }
}

print(need);

	var n = readline();
	var str = readline().split(" ").sort((x,y)=>y-x);
	var sum = str.reduce((x,y)=>+x+Number(y));

	var temp = 0;
	var res = 0;

	for (var i=0; i<n; i++){
		if (temp>sum-temp) break;
		temp+=+str[i];
		res++;
	}
	print(res);

var numOfCoins = parseInt(readline());
var coins = readline().split(" ");
var sum = 0;

for (var i = 0; i < numOfCoins; i++) {
    sum += parseInt(coins[i]);
}

for (var i = 0; i < numOfCoins - 1; i++) {
    for (var j = 0; j < numOfCoins; j++) {
        if (parseInt(coins[j]) > parseInt(coins[j + 1])) {
            var temp = coins[j];
            coins[j] = coins[j + 1];
            coins[j + 1] = temp;
        }
    }
}

var subtractSum = 0;
var counter = 0;

for (var i = numOfCoins - 1; (subtractSum <= sum); i--) {
    sum -= parseInt(coins[i]);
    subtractSum += parseInt(coins[i]);
    counter++;
}

print(counter);

function toint(x) { return parseInt(x, 10); }
function arraySum(a) { return a.reduce(function(prev, x) { return prev + x; }, 0); }
readline();
coins = readline().split(' ')
    .map(function(x) {
        return +x;
    }).sort(function(a, b) {
        return a < b ? -1 : a == b ? 0 : 1;
    }).reverse();
sum = arraySum(coins);
ntaken = 0, sumtaken = 0;
for (var i = 0; i < coins.length && sumtaken <= sum/2; ++i) {
    sumtaken += coins[i];
    ntaken++;
}
print(ntaken);

var n = +readline();
var a = readline().split(' ').map(function(v){ return +v; });
a.sort(function(a, b){return b-a;});
var sum = a.reduce(function(a, b){ return a+b;}, 0);
var b=0;
for(var i=0; b<=sum; i++){
	b+=a[i];
	sum-=a[i];
}
print(i);

var n = +readline(), a = readline().split(" ");

a.sort(function(a,b){return b-a});

if( n == 1 ){
	write(1);
}
else{
	for(i = 1; i < n; i++){
		var sum1 = 0, sum2 = 0;
		for(j = 0; j < i; j++){
			sum1 += +a[j];
		}
		for(k = i; k < n; k++){
			sum2 += +a[k];
		}
		if( sum1 > sum2 ){
			write(i);
			break;
		}
		if( sum1 == sum2 && n == 2 ){
			write(2);
		}
	}
}

var len=parseInt(readline());

var x=readline().split(' ').map(x => parseInt(x));

x.sort((a,b) => b-a);

var count=0;
var sum=0;
var maxSum=0;

for(var i=0; i<len; i++){
  sum+=x[i];
}

for(var i=0; i<len; i++){
  maxSum+=x[i];
  count++;
  if(maxSum> sum-maxSum){
    break;
  }
}

print(count);

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0; i < dataMas.length; i++) {
    dataMas[i] = parseInt(dataMas[i]);
    for (var j = i+1; j < dataMas.length; j++) {
        dataMas[j] = parseInt(dataMas[j]);
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0; sum2 <= sum; i++) {
    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);

    answer = answer + 1;
}

write(answer);

const main = () => {
  readline();

  var sum = 0;

  const coins = readline()
    .split(" ")
    .map((coin) => {
      var numCoin = Number(coin);

      sum += numCoin;

      return numCoin;
    })
    .sort((a, b) => a - b);

  var currSum = 0;
  var currIndex = coins.length - 1;

  while (currSum <= sum / 2) {
    currSum += coins[currIndex];
    currIndex--;
  }

  return coins.length - currIndex - 1;
};

print(main());

var n     = readline(),
    coins = readline().split(' ').sort((a, b) => a - b).reverse().map(Number),
    sum   = coins.reduce((a, b) => a + b),

    targeted = sum / 2,
    mySum = 0,
    count = 0;
    for(var v of coins) {

        if(mySum > targeted)
            break;
        else
            mySum += v;
            count++;
    }

    print(count);

function readn() {
	return +readline();
}
function readns(s) {
	return s.split(" ").map(function(x) { return +x; });
}
function sortNumber(a,b) {
	return a-b;
}

var n = readn();
var ss = readline();
var a = readns(ss);

a = a.sort(sortNumber).reverse();

var fullSum = a.reduce(function(prev, current){
	return prev+current;
});

var sum1 = 0;
for (var i = 0; i < a.length; i++) {
	sum1 += a[i];
	if (sum1 > fullSum/2 + 1e-6) {
		print(i+1);
		break;
	}
}

var n = parseInt(readline());
var f = function(num) {return parseInt(num);};
var line = readline().split(' ').map(f);
line.sort(function(a, b) {return b - a});
var sumLine = function(from){
    var s = 0;
    for(var i = from;i < line.length;i++){
        s += line[i];
    }
    return s;
};
var m = line[0];
var c = 1;
for(var i = 1; i < line.length; i++){
    var sum = sumLine(i);
    if(m >= sum){
        if(m === sum) c++;
        break;
    }
    m += line[i];
    c++;
}
print(c);

/* TEST CASE
input
2
3 3
output
2
input
3
2 1 2
output
2

Input
7
1 10 1 2 1 1 1
Output
2
Answer
1

 */

function main() {
	var n = parseInt(readline());
	var a = new Array(n);
	var answer = 0;
	var i;
	var sum = 0;
	var splitted = readline().split(' ');

	for (i = 0; i < n; i++) {
		a[i] = parseInt(splitted[i]);
		sum += a[i];
	}
	var half = (sum >> 1);
	sum = 0;
	a.sort(function(v1, v2) {return v1 - v2;});
//FOR DEBUG:	print(a);
	for (i = n - 1; i >= 0 && sum <= half; i--) {
		sum += a[i];
	}
	answer = n - 1 - i;
	print(answer);
}

main();

var monedas = +readline();
var valores = readline().split(" ").map(function(v){return +v;}).sort(function(a,b) {return b-a;});
var suma = valores.reduce(function(a,b) {return a+b;},0);
var numMonedas = 0;
var contador = 0;

for (var i = 0; i<monedas; i++) {
    if (contador<=suma/2) {
        contador+=valores[i];
        numMonedas++;
    }
}
print(numMonedas);

var n = Number(readline()), array = readline().split(" ").map(x => Number(x)), coinCount = 0;
function arrayDescend(array) {
	var result = Array.from(array);
	for (var i = 0; i < result.length - 1; i++) {
		for (var j = 0; j < result.length - i - 1; j++) {
			if (result[j] < result[j + 1]) {
				var temp = result[j];
				result[j] = result[j + 1];
				result[j + 1] = temp;
			}
		}
	}
	return result;
}
array = arrayDescend(array);
for (var i = 1; i <= array.length; i++) {
	var mySum = array.slice(0, i).reduce((a, b) => a + b);
	var brotherSum = 0;
	if (i != array.length) brotherSum = array.slice(i).reduce((a, b) => a + b);
	if (mySum > brotherSum) {
		coinCount = i;
		break;
	}
}
print(coinCount);

var n = parseInt(readline());
var s = readline().split(' ').map(Number).sort(function(a, b){return b-a});

var minCoin = 0;
var sumAll = s.reduce((a,b)=>a+b, 0);

var curSum = 0;
var needSum = Math.floor(sumAll/2);
for (var i = 0; i < s.length; i++) {
    minCoin++;
    curSum+=s[i];
    if (curSum > needSum) {
        break;
    }
}

print(minCoin);

var counts = Number(readline()),
    data = readline().split(' '),
    i = 0;

var summ = 0,
    summ1 = 0;

data.map(function(c) {
    summ += Number(c);
});

data.sort(function(a, b) {
    return b-a;
});

do {
    summ1 += Number(data[i]);
    i++;
} while (summ1 <= summ - summ1);

print(i);

function sortByIncrease(a,b)
{
    return a - b;
}
function NeedSumForMeanMe(str)
{
    str = str.split(' ');
    for (var i = 0 ; i <=str.length - 1; i++)
    {
        str[i] = +str[i];
    }
    str = str.sort(sortByIncrease);
    var sum = str[str.length - 1], res = 1;
    for (i = str.length - 2; i >= 0; i--)
    {
		var sumstr = 0;
        for (var i1 = i; i1 >= 0; i1--)
        {
            sumstr += str[i1];
        }
        if (sum > sumstr) break;
        else
        {
			res += 1;
            sum += str[i];
        }
    }
    return res;

}
{
    var num = readline();
    var input = readline();
    num = +num;
    print(NeedSumForMeanMe(input));

}

var n = readline();
var coins = readline().split(" ").sort(function(a,b){
	return parseInt(a)-parseInt(b);
});
var sum = coins.reduce(function(a,b){
	return parseInt(a)+parseInt(b);
},0);
var uTake = 0;
var uTakeN = 0;
for(var i = n-1; i >= 0; i--){
	uTake += parseInt(coins[i]);
	uTakeN++;
	if(uTake > (sum - uTake))
		break;
}
print(uTakeN);

var num = readline();
var coins = readline().split(" ");
var total = 0;
var min = 0;
var count = 0;
coins.sort(function(a, b) {
  return b - a;
});

for(var i = 0; i < coins.length; i++){
    total = total + parseInt(coins[i]);
}

for(var j = 0; j < coins.length; j++){
    min = min + parseInt(coins[j]);
    if(min > total/2){
        count = count + 1;
        break;
    }
    count = count + 1;
}

print(count);

var n = parseInt(readline(), 10),
    inp = readline().split(' ').map(el => parseInt(el, 10)).sort((a,b) => b-a),
    totalMoney = 0,
    tempMoney = 0;
    coin = 0;

totalMoney = inp.reduce((a,b) => a+b);

while(1) {

    tempMoney += inp[coin];

    if(tempMoney > totalMoney/2) break;

    coin++;
}

print(++coin);

var n = parseInt(readline(), 10),
    inp = readline().split(' ').map(el => parseInt(el, 10)).sort((a,b) => b-a),
    totalMoney = 0,
    tempMoney = 0,
    coin = 0;

totalMoney = inp.reduce((a,b) => a+b);

while(1) {

    tempMoney += inp[coin];

    if(tempMoney > totalMoney/2) break;

    coin++;
}

print(++coin);

var n = readline();
var input = readline().split(" ").map(Number).sort(function (a, b) {
	return b - a;
});

var sum = input.reduce(function (prev, next) {
	return prev + next;
});

var temp = 0,
	coins = 0;

for (var i = 0; i < input.length; i++) {
	if (temp > sum) {
		break;
	}

	temp += input[i];
	sum -= input[i];
	coins++;
}

print(coins);

var coinsCount = readline();
var coinsArr = readline().split(' ').sort(sortNumber);
// print(coinsArr);

var maxSum = findArrSum(coinsArr);
print(findCoinsCount(coinsArr));

function findCoinsCount(arr){

    var mySum = 0;
    var myCointCount = 0;
    var remaining = 0;

    for (var i = arr.length - 1; i > -1; i--){

        mySum += Number(arr[i]);
        myCointCount++;
        remaining = maxSum - mySum;

        // print('mySum', mySum);
        // print('remaining', remaining);

        if (mySum > remaining){
            return myCointCount;
        }
    }
}

function findArrSum(arr){
    var sum = 0;
    for (var j = 0; j < arr.length; j++){
        arr[j] = Number(arr[j]);
        sum += arr[j];
    }
    return sum;
}

function sortNumber(a,b) {
        return a - b;
    }

// function findArrSum(arr, indStart, indEnd){
//     var sum = 0;
//     for (var j = indStart; j < indEnd + 1; j++){
//         sum += Number(arr[j]);
//     }
//     return sum;
// }

var n = Number(readline())
var arr = readline()

function getCoins(n, arr) {
    arr = arr.split(' ').map(i => Number(i)).sort((a, b) => {
        if(a > b) return -1
        return 1
    })

    var result = []
    var sum = arr.reduce((a, b) => a + b, 0)

    for(var i of arr) {
        result.push(i)
        var resultSum = result.reduce((a, b) => a + b, 0)
        if(resultSum > (sum / 2)) {
            return result.length
        }
    }

    return result.length
}

print(getCoins(n, arr))

readline();
var list = readline().split(' ').sort(function(a,b){ return b-a;});
  var total = 0;
  for (var i = 0; i < list.length; i++) {
    total += parseInt(list[i]);
  }
  var index = 0;
  var amount = 0;
  while (amount <= total-amount && index < list.length) {
    amount += parseInt(list[index]);
    index++;
  }
  print(index) ;

var n = readline();
n = readline().split(' ').map(function(each) {return Number(each);});
n.sort(function(a, b) {
    return a - b;
});

var remains = 0;
for (var i = 0; i < n.length; ++i)
    remains += n[i];

var mine = 0;

i = n.length - 1;
while (remains >= mine && i >= 0) {
    mine += n[i];
    remains -= n[i];
    --i;
}

print(n.length - i - 1);

var ln = +readline();
var coins = readline().split(' ').map(e => +e).sort((a, b) => a - b).reverse();

for (var i=0; i<coins.length; i++) {
  var left = eval(coins.slice(0, i+1).join('+'));
  var right = eval(coins.slice(i+1).join('+')) || 0;

  if (left > right) {
    write(String(i + 1) + '\n');
    break;
  }
}

var s = Number(readline())
var res = 0
var j =readline().split(" ")
var max  = 0

function sortNumber(a,b) {
    return a - b;
}
j.sort(sortNumber);
j.reverse()

for (var i = 0; i < s; i++) {

    var ab = j.slice(0, i + 1).reduce((a, b) => Number(a) + Number(b), 0)
    var bb = j.slice(i + 1, s + 1).reduce((a, b) => Number(a) + Number(b), 0)

    if(ab > bb) {
        res = i + 1
        break;
    }
}

print(res)

// Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.

// Now let's imagine a typical morning in your family. You haven't woken up yet, and Mom is already going to work. She has been so hasty that she has nearly forgotten to leave the two of her darling children some money to buy lunches in the school cafeteria. She fished in the purse and found some number of coins, or to be exact, n coins of arbitrary values a1, a2, ..., an. But as Mom was running out of time, she didn't split the coins for you two. So she scribbled a note asking you to split the money equally.

// As you woke up, you found Mom's coins and read her note. "But why split the money equally?" — you thought. After all, your twin is sleeping and he won't know anything. So you decided to act like that: pick for yourself some subset of coins so that the sum of values of your coins is strictly larger than the sum of values of the remaining coins that your twin will have. However, you correctly thought that if you take too many coins, the twin will suspect the deception. So, you've decided to stick to the following strategy to avoid suspicions: you take the minimum number of coins, whose sum of values is strictly more than the sum of values of the remaining coins. On this basis, determine what minimum number of coins you need to take to divide them in the described manner.

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

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

var n = readline()
var c = readline().split(" ").sort((a, b) => (a - b)).reverse()
var s = 0

function add(a, b){
    return +a + +b;
}

for (i=0; i<n; i++){
    s += +c[i];
    if (s>c.reduce(add)-s){
        print(i+1);
        break;
    }
}

var n = Number(readline());
var amt = readline().split(' ').map((cur) => Number(cur));
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(Math.max(...amt)),1);
sum = amt.reduce((acc, c) => {
    return acc + c;

} ,0);
}

print(count);

(function main() {
    //var s1 = readline().toLowerCase();
    //var s2 = readline().toLowerCase();
    var n = readline().split(' ').map(Number);
    var a = readline().split(' ').map(Number);

    for (var i = 0; i < n - 1; i++) {
        for (var j = i + 1; j < n; j++) {
            if (a[i] < a[j]) {
                var tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    var sum = 0, sumIn = 0;
    for (i = 0; i < n; i++) {
        sum += +a[i];
    }

    for (i = 0; i < n; i++){
        if (sumIn > sum) {
            print(i);
            return;
        }
        sumIn += a[i];
        sum -= a[i];
    }
    print(n);
})()

var n = parseInt(readline());
var coins = readline().split(' ').map(Number);
coins.sort(function(a, b){
    return b - a;
});
var totalSum = coins.reduce(function(a,b){
    return a + b;
});
var mySum = 0;
var counter = 0;

while ((mySum <= (totalSum - mySum)) && (coins.length > 0)){
    mySum += coins[0];
    counter ++;
    coins.shift();
}
print(counter);

var coinNum = +readline();
var coins = readline().split(' ').map(function(v){return +v;}).sort(function(a, b){return b-a;});
var acc = 0;
var result = 0;

var total = 0;

for (var i=0; i<coinNum; i++) {
    total += coins[i];
}

for (var i=0; i<coinNum; i++) {
    if (acc > total/2) {
        break;
    }
    acc += coins[i];
    result++;
}

print(result);

var limit = parseInt(readline());
var count = 0, mySum = 0;
var coins = readline().split(' ').map(x => parseInt(x));
var totalSum = coins.reduce((a,b) => a+b, 0);
coins.sort((a,b) => b - a);
for (var i = 0; i < limit; i++) {
  mySum += coins[i];
  count++;
  if (mySum > totalSum - mySum) break;
}
print(count);

n = parseInt(readline());
k = readline().split(" ");
k = k.sort(function(a,b){return b - a});
var jam = 0;
var count = 0;
sum = k.reduce((a, b) => parseInt(a) + parseInt(b)) / 2;
for( var i = 0 ; i < n  ; i++){
	jam = jam + parseInt(k[i]);
	count = count +1 ;
	if(jam > sum){break;}
}
print(count);

var nums = readline();
var coins = readline().split(" ").map(Number).sort((a, b) => b - a);
var total = coins.reduce((acc, curr) => acc + curr, 0);

var my = 0;
var twin = total;
var count = 0;

for (var i = 0; i < coins.length; i++) {
    my += coins[i];
    twin -= coins[i];
    count = i + 1;

    if (my > twin) {
        break;
    }
}

print(count);

//var input = "3\n2 1 2";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function main(){
    var n = parseInt(readline());
    var arr = readline().split(' ');
    var sum = 0;
    var ans = 0;
    for(var i = 0; i < arr.length; i++){
        arr[i] = parseInt(arr[i]);
        sum += arr[i];
    }
    arr.sort(function(a, b){
        return a - b;
    });
    var index = arr.length - 1;
    while(ans <= sum){
        ans += arr[index];
        sum -= arr[index];
        index--;
    }
    print(arr.length - index - 1);
}
main();

function readNumbers() {
	return readline().split(' ').map(function (x) {
		return parseInt(x);
	});
}

var n = parseInt(readline());
var coins = readNumbers();

coins.sort(function (a, b) {
	return b - a;
});

var sum = 0;

for (var i = 0; i < n; i++) {
	sum += coins[i];
}

var part = 0;
var count = 0;

for (var i = 0; i < n; i++) {
	part += coins[i];
	count++;

	if (part > sum / 2) {
		break;
	}
}

print(count)

var print = this.print || require('lol-io').print
var write = this.write || require('lol-io').write
var readLine = this.readline || require('lol-io').readline

var num=readLine().split(' ')[0];

var arr=readLine().split(' ').map(i=>parseInt(i));

var max=0;
var sum=0;
var count=0;
var s=0;
arr.sort(function(a,b){return b-a});
for(var i=0;i<arr.length;i++){
    sum+=arr[i];
}
//console.log(sum)

//console.log(arr)
/*
for(var i=0;i<arr.length;i++){
    count++;
            if(s!=i)
              max+=arr[i];
          if(Math.floor(sum/2)<max){
            break;
          }

}*/
var ans=0;
var j=0;
while(ans<=Math.floor(sum/2)){
    count++;
    ans+=arr[j];
    j++;
}

print(count);

var nums = readline();
var coins = readline().split(" ").map(Number).sort((a, b) => b - a);
var total = coins.reduce((acc, curr) => acc + curr, 0);

var my = 0;
var twin = total;
var count = 0;

for (var i = 0; i < coins.length - 1; i++) {
    my += coins[i];
    twin -= coins[i];
    count = i + 1;

    if (my > twin) {
        break;
    }
}

print(count);

n = parseInt(readline());
k = readline().split(" ");
k = k.sort(function(a,b){return b - a});
var jam = 0;
var count = 0;
sum = k.reduce((a, b) => parseInt(a) + parseInt(b)) / 2;
for( var i = 0 ; i < n  ; i++){
	jam = jam + parseInt(k[i]);
	count = count +1 ;
	if(jam > Math.ceil(sum)){break;}
}
print(count);

var num = readline();
var coins = readline().split(" ");
var total = 0;
coins.sort(function(a, b) {
  return a - b;
});

for(var i = 0; i < coins.length; i++){
    total = total + parseInt(coins[i]);
}

print(total);

const readline = require('readline');

let inputs = [];

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

// Read Inputs
rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Excute algorithm
rl.on('close', () => {

    const numOfCoins = inputs[1].split(' ').length;
    const coinsValue = inputs[1].split(' ').sort((a, b) => b - a);
    const totalValue = inputs[1].split(' ').reduce((accum, c) => accum += parseInt(c), 0)
    const minVal = (totalValue / 2) + 1;
    let minNumOfCoins = 0;
    let myValue = 0;

    for (let i = 0; i < numOfCoins; i++) {

        console.log('myVal: ', myValue, ' minVal: ', minVal, ' NoOfCoins: ', minNumOfCoins)

        if (myValue < minVal) {
            myValue += parseInt(coinsValue[i])
            minNumOfCoins++
        } else {
            return console.log(minNumOfCoins)
        }
    }

    return console.log(minNumOfCoins)

})

var  number=readline();
var  coins=readline();
var array = coins.split(" ").map(Number);
array.sort(function(a, b){return a - b});
var sumCoins=0;
var result=0;
for( i=0;i<number;i++) {
sumCoins=sumCoins+array[i];
}
function getResult() {
for( i=0;i<number;i++) {
var sumI=0;
  for( k=0;k<=i;k++) {
	sumI=sumI+array[k];
}
if(sumI>=sumCoins-sumI) {
	result=number-i+1
  return result
}
result=1;
return result
}
}

print(getResult())

var numberOfCoin  = 5,
    temp = "2 2 2 2 4",
    sum = 0 ,
    coins = temp.split(" ").sort(),
    counter=coins[numberOfCoin-1];
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);
        break;
    }
}

var n = Number(readline());
var amt = readline().split(' ');
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;

while(max <= sum){
count++;
max = Math.max(...amt);
amt.splice(amt.indexOf(max),1);
sum = amt.reduce((acc, c) => {
    return acc + c
},0);
}

print(count);

var numberOfCoin  = 5,
    coins = "2 2 2 2 4",
    sum = 0, counter=coins[numberOfCoin-1];
    coins.split(" ").sort();
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
print(sum);

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// thats all what you have to write to get input from stdin, using readLine.

// Main code runs in main();

function main(){

    let coinCount =Number.parseInt( readline());
    let coins = readline().split(" ").map( (item) => Number.parseInt(item));
    // desc
    coins = coins.sort();

    let picked = [];
    let notPicked = coins;
    while(true) {

         picked.push(notPicked.pop());

         let pickedSum =  picked.reduce((a , b) => a + b, 0)
         let notPickedSum = notPicked.reduce((a,b) => a + b, 0);
         if(pickedSum > notPickedSum)
         {
            process.stdout.write(picked.length.toString());
             break;
         }

    }

}

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }
}

for (var i = 0, length = dataMas.length - 1; flag!==true; i++) {
    sum += dataMas[i];
    sum2 = 0;

    for (var j = i+1; i < length; i++) {
        sum2 += dataMas[j];
    }

    if (sum <= sum2) {
        answer += 1;
        flag = true;
    }
}

write(answer);

var n = Number(readline());
var amt = readline().split(' ').map((cur) => Number(cur));
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;
print('Initial sum :' + sum);

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(Math.max(...amt)),1);
sum = amt.reduce((acc, c) => {
    return acc + c;

} ,0);
print(max);
print(sum);
}

print(count);

var n = +readline();
var a = readline().split(' ').map(function(v){ return +v; });
a.sort(function(a, b){return a>b;});
var sum = a.reduce(function(a, b){ return a+b;}, 0);
var b=0;
for(var i=0; b<=sum; i++){
	b+=a[i];
	sum-=a[i];
}
print(i);

/* TEST CASE
input
2
3 3
output
2
input
3
2 1 2
output
2

Input
7
1 10 1 2 1 1 1
Output
2
Answer
1

 */

function main() {
	var n = parseInt(readline());
	var a = new Array(n);
	var answer = 0;
	var i;
	var sum = 0;
	var splitted = readline().split(' ');

	for (i = 0; i < n; i++) {
		a[i] = parseInt(splitted[i]);
		sum += a[i];
	}
	var half = (sum >> 1);
	sum = 0;
	a.sort(function(v1, v2) {return v1 - v2;});
	print(a);
	for (i = n - 1; i >= 0 && sum <= half; i--) {
		sum += a[i];
	}
	answer = n - 1 - i;
	print(answer);
}

main();

var n = Number(readline())
var arr = readline()

function getCoins(n, arr) {
    arr = arr.split(' ').map(i => Number(i)).sort((a, b) => b - a ? -1 : 1)

    var result = []
    var sum = arr.reduce((a, b) => a + b, 0)

    for(var i of arr) {
        result.push(i)
        var resultSum = result.reduce((a, b) => a + b, 0)
        if(resultSum > (sum / 2)) {
            return result.length
        }
    }

    return result.length
}

print(getCoins(n, arr))

/* TEST CASE
input
2
3 3
output
2
input
3
2 1 2
output
2
 */

function main() {
	var n = parseInt(readline());
	var a = new Array(n), g = new Array(n);
	var answer = 0;
	var i;
	var sum = 0;
	var splitted = readline().split(' ');

	for (i = 0; i < n; i++) {
		a[i] = parseInt(splitted[i]);
		sum += a[i];
	}
	var half = (sum >> 1);
	sum = 0;
	a.sort();
	for (i = n - 1; i >= 0 && sum <= half; i--) {
		sum += a[i];
	}
	answer = n - 1 - i;
	print(answer);
}

main();

var ln = +readline();
var coins = readline().split(' ').map(e => +e).sort((a, b) => a + b);

for (var i=0; i<coins.length; i++) {
  var left = eval(coins.slice(0, i+1).join('+'));
  var right = eval(coins.slice(i+1).join('+')) || 0;
  if (left > right) {
    write(String(i + 1) + '\n');
    break;
  }
}

// Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.

// Now let's imagine a typical morning in your family. You haven't woken up yet, and Mom is already going to work. She has been so hasty that she has nearly forgotten to leave the two of her darling children some money to buy lunches in the school cafeteria. She fished in the purse and found some number of coins, or to be exact, n coins of arbitrary values a1, a2, ..., an. But as Mom was running out of time, she didn't split the coins for you two. So she scribbled a note asking you to split the money equally.

// As you woke up, you found Mom's coins and read her note. "But why split the money equally?" — you thought. After all, your twin is sleeping and he won't know anything. So you decided to act like that: pick for yourself some subset of coins so that the sum of values of your coins is strictly larger than the sum of values of the remaining coins that your twin will have. However, you correctly thought that if you take too many coins, the twin will suspect the deception. So, you've decided to stick to the following strategy to avoid suspicions: you take the minimum number of coins, whose sum of values is strictly more than the sum of values of the remaining coins. On this basis, determine what minimum number of coins you need to take to divide them in the described manner.

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

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

var n = readline()
var c = readline().split(" ").sort().reverse()
var s = 0

function add(a, b){
    return +a + +b;
}

for (i=0; i<n; i++){
    s += +c[i];
    if (s>c.reduce(add)-s){
        print(i+1);
        break;
    }
}

'use strict';
let _ = readline(),
    totalAmount = 0,
    outAmount = 0,
    array = readline().split(' ').map(function(value){
        value = parseInt(value);
        totalAmount += value
        return value;
    }).sort().reverse();

let i = 0;
for(; totalAmount >= outAmount; i++){
    totalAmount -= array[i];
    outAmount += array[i];
}

write(i)

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += dataMas[i];
}

for (var i = 0, length = dataMas.length; !flag; i++) {
    sum2 += dataMas[i];
    sum -= dataMas[i];

    if (sum2 < sum) {
        answer = answer + 1;
    }
    else {
        answer = answer + 1;
        flag = true;
    }
}

write(answer);

var n = readline();
var a = readline()
  .split(" ")
  .map((a) => parseInt(a));
var sum = a.reduce((x, y) => x + y, 0);
var x = Math.floor(sum / 2);
var final_sum = 0;
var count = 0;
var new_array= a.sort();
var new_arr = new_array.reverse();
for (var i = 0; i < n; i++) {
  final_sum += new_arr[i];
  count++;
  if (final_sum > x) {
    print(count);
    break;
  }
}

var n = Number(readline())
var arr = readline().split('').map(i => Number(i))

function getCoins(n, arr) {
    var result = []
    var sum = arr.reduce((a, b) => a + b, 0)

    for(var i of arr) {
        result.push(i)
        if(result.reduce((a, b) => a + b, 0) > (sum / 2)) {
            break
        }
    }

    return result.length
}

print(getCoins(n, arr))

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0, length = dataMas.length; !flag; i++) {
    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);

    if (sum2 <= sum) {
        answer = answer + 1;
    }
    else {
        answer = answer + 1;
        flag = true;
    }
}

write(answer);

var monedas = +readline();
var valores = readline().split(" ").map(function(v){return +v;}).sort(function(a,b) {return b-a;});
var suma = valores.reduce(function(a,b) {return a+b;},0);
var numMonedas = 0;
var contador = 0;

for (var j = 0; contador<suma; j++) {
    contador+=valores[j];
    suma-=valores[j];
}
    print(j);

var n = Number(readline())
var arr = readline().split(' ').map(i => Number(i)).sort((a, b) => b - a ? 1 : -1)

function getCoins(n, arr) {
    var result = []
    var sum = arr.reduce((a, b) => a + b, 0)

    for(var i of arr) {
        result.push(i)
        var resultSum = result.reduce((a, b) => a + b, 0)
        if(resultSum > (sum / 2)) {
            break
        }
    }

    return result.length
}

print(getCoins(n, arr))

readline();
var arr = readline().split(" ");
arr.sort((a,b) => b - a);
var s1 = arr.reduce((a, b) => a + b) / 2;
var s2 = 0;
for (var i = 0; s2 <= s1 && i < arr.length; ++i) {
    s2 += arr[i];
}
print(i);

readline();
var arr = readline().split(" ");
arr.sort((a,b) => b - a);
var s1 = arr.reduce((a, b) => a + b) / 2;
var s2 = 0;
for (var i = 0; s1 <= s2; ++i) {
    s2 += arr[i];
}
print(i);

var n = +readline();
var a = readline().split(' ').map(function(v){ return +v; });
a.sort(function(a, b){return a<b;});
var sum = a.reduce(function(a, b){ return a+b;}, 0);
var b=0;
for(var i=0; b<=sum; i++){
	b+=a[i];
	sum-=a[i];
}
print(i);

var n = readline();
var c = readline().split(" ").sort(function(a, b) {
  return a - b;
});
c.reverse();
var f = 0;
var sum1=0;
var sum2=0;
var s=0;
for (i=0;i<c.length;i++)
sum2=sum2+c[i];
while (f===0)
{
    if (sum2>sum1)
    {
    sum2=sum2-c[s];
    sum1=sum1+c[s];
    s++;
    }
    else f=1;
}
print(s);

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += dataMas[i];
}

for (var i = 0, length = dataMas.length; !flag && i <= length; i++) {
    sum2 += dataMas[i];
    sum -= dataMas[i];

    if (sum2 <= sum) {
        answer = answer + 1;
    }
    else {
        flag = true;
    }
}

write(answer);

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

// thats all what you have to write to get input from stdin, using readLine.

// Main code runs in main();

function main(){

    let coinCount =Number.parseInt( readline());
    let coins = readline().split(" ").map( (item) => Number.parseInt(item));
    // desc
    coins = coins.sort();

    let picked = [];
    let notPicked = coins;
    while(true) {

         picked.push(notPicked.pop());
        console.log(notPicked);

         let pickedSum =  picked.reduce((a , b) => a + b, 0)
         let notPickedSum = notPicked.reduce((a,b) => a + b, 0);
         if(pickedSum > notPickedSum)
         {
            process.stdout.write(picked.length.toString());
             break;
         }

    }

}

n = parseInt(readline());
k = readline().split("");
k = k.sort(function(a,b){return b - a});
var jam = 0;
var count = 0;
sum = k.reduce((a, b) => parseInt(a) + parseInt(b));
for( var i = 0 ; i < n - 1 ; i++){
	jam = jam + parseInt(k[i]);
	count = count +1 ;
	if(jam > Math.ceil(sum/2)){break;}
}
print(count);

var numberOfCoin  = 5,
    temp = "2 2 2 2 4",
    sum = 0 ,
    coins = temp.split(" ").sort(),
    counter=coins[numberOfCoin-1];
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);
        break;
    }
}

function readn() {
	return +readline();
}
function readns(s) {
	return s.split(" ").map(function(x) { return +x; });
}
function sortNumber(a,b) {
	return a-n;
}

var n = readn();
var ss = readline();
var a = readns(ss);

a = a.sort(sortNumber).reverse();

var fullSum = a.reduce(function(prev, current){
	return prev+current;
});

if (readline === "4 2 2 2 2") {
print(a);
}
var sum1 = 0;
for (var i = 0; i < a.length; i++) {
	sum1 += a[i];
	if (sum1 > fullSum/2 + 1e-6) {
		print(i+1);
		break;
	}
}

var num = readline();
var coins = readline().split(" ");
var total = 0;
coins.sort(function(a, b) {
  return a - b;
});

for(var i = 0; i <= coins.length; i++){
    total = total + coins[i];
}

print(total);

var  number=readline();
var  coins=readline();
var array = coins.split(" ").map(Number);
array.sort(function(a, b){return a - b});
var sumCoins=0;
var result=0;
for( i=0;i<number;i++) {
sumCoins=sumCoins+array[i];
}
function getResult() {
for( i=0;i<number;i++) {
var sumI=0;
  for( k=0;k<i;k++) {
	sumI=sumI+array[k];
}
if(sumI>=sumCoins-sumI) {
	result=number-i+1
  return result
}
else {
result=1;
return result
}

}
}

print(getResult())

var monedas = readline();
var valorMonedas = readline().split(" ").sort().join();
var sumaTotal = 0;
var sumaParcial =0;
var cantidadMonedas = 0;

for (var i = 0; i<valorMonedas.length; i++) {
    sumaTotal += parseInt(valorMonedas[i]);
}

for (var j = 0; j<valorMonedas.length; j++) {
    sumaParcial += parseInt(valorMonedas[j]);
    if (sumaParcial>sumaTotal/2) {
        if (j%2 === 0) {
            cantidadMonedas = j;
        } else {
            cantidadMonedas = j+1;
        }
    }
}

print(cantidadMonedas);

var print = this.print || require("lol-io").print;
var write = this.write || require("lol-io").write;
var readline = this.readline || require("lol-io").readline;
var n = readline();
var a = readline()
  .split(" ")
  .map((a) => parseInt(a));
var sum = a.reduce((x, y) => x + y, 0);
var x = Math.floor(sum / 2);
var final_sum = 0;
var count = 0;
var new_arr = a.sort().reverse();
for (var i = 0; i < n; i++) {
  final_sum += new_arr[i];
  count++;
  if (final_sum > x) {
    print(count);
    break;
  }
}

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort(),
    sum = 0, counter=coins[numberOfCoin-1];
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);
        break;
    }
}

function readn() {
	return +readline();
}
function readns() {
	return readline().split(" ").map(function(x) { return +x; });
}
function sortNumber(a,b) {
	return a-n;
}

var n = readn();
var a = readns();

a = a.sort(sortNumber).reverse();

var fullSum = a.reduce(function(prev, current){
	return prev+current;
});

var sum1 = 0;
for (var i = 0; i < a.length; i++) {
	sum1 += a[i];
	if (sum1 > fullSum/2 + 1e-6) {
		print(i+1);
		break;
	}
}

var coinNum = +readline();
var coins = +readline().split(" ");
var acc = 0;
var result = 0;

var total = 0;

for (var i=0; i<coinNum; i++) {
    total += coins[i];
}

for (var i=0; i<coinNum; i++) {
    if (acc > total/2) {
        print(result);
    }
    acc += coins[i];
    result++;
}

var n = Number(readline())
var arr = readline()

function sort(array) {
    var newArr = []

    while(array.length === newArr.length) {
        var max = Math.apply.max(null, array)
        newArr.push(max)
        array.splice(array.indexOf(max), 1)
    }

    return newArr
}

function getCoins(n, arr) {
    arr = sort(arr.split(' ').map(i => Number(i)))

    var result = []
    var sum = arr.reduce((a, b) => a + b, 0)

    for(var i of arr) {
        result.push(i)
        var resultSum = result.reduce((a, b) => a + b, 0)
        if(resultSum > (sum / 2)) {
            return result.length
        }
    }

    return result.length
}

print(getCoins(n, arr))

var n = Number(readline());
var amt = readline().split(' ');
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(max),1);
sum = amt.reduce((acc, c) => {
    return acc + c
},0);
}

print(count);

var num = readline();
//var coins = readline().split(" ");

var coins = [5,4,3,5,8,3,1];

coins.sort(function(a, b) {
  return a - b;
});

print(coins[0]);
print(coins[1]);
print(coins[2]);
print(coins[3]);
print(coins[4]);
print(coins[5]);
print(coins[6]);

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort(),
    sum = 0;
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
var counter=coins[numberOfCoin-1];
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);
        break;
    }
}

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += dataMas[i];
}

for (var i = 0, length = dataMas.length; !flag; i++) {
    sum2 += dataMas[i];
    sum -= dataMas[i];

    if (sum2 < sum) {
        answer = answer + 1;
    }
    else {
        flag = true;
    }
}

write(dataMas);

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort(),
    sum = 0, counter=0;
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
print(sum);

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort(),
    sum = 0,
    counter=0;
for(var i =0; i < numberOfCoin; i++){
    sum+=coins[i];
}
for(var i = numberOfCoin -1; i >=0; i--){
     if(counter > Math.ceil(sum/2)){
        print(i);
    }
    else{
        counter+=coins[i];
    }
}

var n = readline();
var a = readline()
  .split(" ")
  .map((a) => parseInt(a));
var sum = a.reduce((x, y) => x + y, 0);
var x = Math.floor(sum / 2);
var final_sum = 0;
var count = 0;
for (var i = 0; i < n; i++) {
  final_sum += a[i];
  count++;
  if (final_sum > x) {
    print(count);
    break;
  }
}

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0, length = dataMas.length; !flag && i < length; i++) {
    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);

    if (sum2 <= sum) {
        answer = answer + 1;
    }
    else {
        flag = true;
    }
}

write(answer);

var n = readline();
var a = readline()
  .split(" ")
  .map((a) => parseInt(a));
var sum = a.reduce((x, y) => x + y, 0);
var x = Math.floor(sum / 2);
var final_sum = 0;
var count = 0;
var new_array= a.sort();
var new_arr = new_array.reverse();
for (var i = 0; i < n; i++) {
  final_sum += new_arr[i];
  count++;
  if (final_sum > x) {
    print(count);
    break;
  }
}

var numberOfCoin  = 5,
    temp = "2 2 2 2 4",
    sum = 0 ,
    coins = temp.split(" ").sort(),
    counter=coins[numberOfCoin-1];
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
print(sum);

var n = readline();
var c = readline().split(" ").sort(function(a, b) {
  return a - b;
});
c.reverse();
var f = 0;
var sum1=0;
var sum2=0;
var s=0;
for (i=0;i<c.length;i++)
sum2=sum2+c[i];
while (f===0)
{
    if (sum2>sum1)
    {
    sum2=sum2-c[s];
    sum1=sum1+c[s];
    s++;
    }
    else f=1;
}
print(s);

var n = Number(readline());
var amt = readline().split(' ').map((cur) => Number(cur));
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(max),1);
sum = amt.reduce((acc, c) => {
    return acc + c;

} ,0);
}

print(count);//

readline();
coins = readline().split(' ').map(function(x) { return +x; }).sort().reverse();
sum = coins.reduce(function(prev, x) { return prev + +x; });
taken = [];
for (var i = 0; i < coins.length && taken <= sum/2; ++i) {
    taken.push(coins[i]);
}
print(taken.length);

var n = parseInt(readline());
var f = function(num) {return parseInt(num);};
var line = readline().split(' ').map(f);
var hi = Math.floor(line.length / 2);
var hj = hi + 1;
var lr = 0;
var rl = 0;
var countLr = 0;
var countRl = 0;
for(var i = 0; i <= hi; i++){
    countLr += 1;
    lr += line[i];
}
for(var i = line.length - 1; i >= hj; i--){
    countRl += 1;
    rl += line[i];
}
print(lr >  rl ? countLr : countRl);

var num = readline();
var coins = readline().split(" ");
var total = 0;
coins.sort(function(a, b) {
  return a - b;
});

for(var i = 0; i <= coins.length; i++){
    total = total + coins[i];
}

print(total);

var n = Number(readline())
var arr = readline().split('').map(i => Number(i))

function getCoins(n, arr) {
    var result = []
    var sum = arr.reduce((a, b) => a + b, 0)

    for(var i of arr) {
        result.push(i)
        if(result.reduce((a, b) => a + b, 0) > (sum / 2)) {
            break
        }
    }

    return result.length
}

print(getCoins(n, arr))

function readn() {
	return +readline();
}
function readns() {
	return readline().split(" ").map(function(x) { return +x; });
}

var n = readn();
var a = readns();

a = a.sort().reverse();

var fullSum = a.reduce(function(prev, current){
	return prev+current;
});

if (a[0] === 10) {
print(999);
}
var sum1 = 0;
for (var i = 0; i < a.length; i++) {
	sum1 += a[i];
	if (sum1 > fullSum/2 + 1e-6) {
		print(i+1);
		break;
	}
}

n = parseInt(readline());
k = readline().split(" ");
k = k.sort(function(a,b){return b - a});
var jam = 0;
var count = 0;
sum = k.reduce((a, b) => parseInt(a) + parseInt(b)) / 2;
for( var i = 0 ; i < n  ; i++){
	jam = jam + parseInt(k[i]);
	count = count +1 ;
	if(jam > Math.ceil(sum)){break;}
}
print(count);

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort()
    sum = 0,
    counter=0;
for(var i =0; i < numberOfCoin; i++){
    sum+=coins[i];
}
while(numberOfCoin--){
    if(counter > Math.ceil(sum/2)){
        print(numberOfCoin)
    }
    else{
        counter+=coins[numberOfCoin];
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let standardInputString = '';
let currentLine = 0;

function readLine() {
    return standardInputString[currentLine++];
}

process.stdin.on('data', rawData=> {
    standardInputString += rawData;
})

process.stdin.on('end', _ => {
    standardInputString = standardInputString.trim().split('\n').map(line=> {
        return line.trim();
    })
    main();
})

function main() {
    const coinsNumber = +(readLine());
    const coin = readLine().split(" ").join("");
    let sum = eval(coin.split("").join("+"));
    const minimum = sum / 2;
    let possible = 0;
    let count = 0;
    const sorted = Array.from(coin).sort();
    for(let i = sorted.length - 1; i >= 0; i--) {
        possible = possible + (1* sorted[i]);
        count++;
        if(possible > minimum) break;
    }
    console.log(count);
}

var n = Number(readline());
var amt = readline().split(' ').map((cur) => Number(cur));
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;
print('Initial sum :' + sum);

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(Math.max(...amt)),1);
sum = amt.reduce((acc, c) => {
    return acc + c;

} ,0);
print(max);
print(sum);
}

print(count);

var quantity = readline();
var digits = readline().split(" ").sort((a, b) => a - b);

function sum(arr) {
	return arr.reduce((sum, item) => sum += +item, 0);
}

digits.reduce((result) => {
	if (result <= sum(digits)) {
		result += +digits.pop();
	}

	return result;
}, 0);

print(quantity - digits.length);

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort(),
    sum = 0;
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
var counter=coins[numberOfCoin-1];
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);
        break;
    }
}

var numberOfCoin  = 7,
    temp = "1 10 1 2 1 1 1",
    coins = temp.split(" ").sort(),
    sum = 0;
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
var counter=coins[numberOfCoin-1];
var i = numberOfCoin -1;
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
    }
    else{
        print(numberOfCoin-i);

    }

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0; sum2 <= sum; i++) {
    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);

    answer = answer + 1;
}

write(answer);

var ln = +readline();
var coins = readline().split(' ').map(e => +e).sort((a, b) => a + b);

for (var i=0; i<coins.length; i++) {
  var left = eval(coins.slice(0, i+1).join('+'));
  var right = eval(coins.slice(i+1).join('+'));

  if (left > right) {
    write(String(i + 1) + '\n');
    break;
  }
}

var coinsCount = readline();
var coinsArr = readline().split(' ').sort();

var maxSum = findArrSum(coinsArr);
// print(maxSum);

print(findCoinsCount(coinsArr));

function findCoinsCount(arr){

    var mySum = 0;
    var myCointCount = 0;

    for (var i = arr.length - 1; i > -1; i--){
        // print(arr[i]);
        mySum += Number(arr[i]);
        myCointCount++;
        var remaining = maxSum - mySum;

        if (mySum > remaining){
            return myCointCount;
        }
    }
}

function findArrSum(arr){
    var sum = 0;
    for (var j = 0; j < arr.length; j++){
        sum += Number(arr[j]);
    }
    return sum;
}

// function findArrSum(arr, indStart, indEnd){
//     var sum = 0;
//     for (var j = indStart; j < indEnd + 1; j++){
//         sum += Number(arr[j]);
//     }
//     return sum;
// }

var n = Number(readline());
var amt = readline().split(' ');
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(max),1);
sum = amt.reduce((acc, c) => {
    return acc + c
},0);
}

print(count);

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0, length = dataMas.length; !flag; i++) {
    if (sum2 <= sum ) {
        answer = answer + 1;
    }
    else {
        flag = true;
    }

    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);
}

write(answer);

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0, length = dataMas.length; !flag; i++) {
    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);

    if (sum2 <= sum ) {
        answer = answer + 1;
    }
    else {
        flag = true;
    }
}

write(answer);

readline();
var nums = readNums();
nums.sort();
var need = nums.reduce((a,b) => a+b) / 2;
var value = 0;
for (var i = nums.length - 1; i >= 0; i--) {
    value += nums[i];
    if (value > need) {
        break;
    }
}
print(nums.length - i);

function readNums() {
    return readline().split(' ').map(v => v - 0);
}

readline();
coins = readline().split(' ').map(function(x) { return +x; }).sort().reverse();
sum = coins.reduce(function(prev, x) { return prev + +x; });
ntaken = 0, sumtaken = 0;
taken = 0
for (var i = 0; i < coins.length && sumtaken <= sum/2; ++i) {
    sumtaken += coins[i];
    ntaken++;
}
print(ntaken);

var n=readline(); n=parseInt(n);
var arr=readline().split(' ').map(function(x){return  parseInt(x)  ; });
arr.sort(); var sum=0;
for( var i=0; i <n;i++)
{
    sum+=arr[i];
} var num=0;
for(var i=0;i<n;i++)
{
    num+=arr[i]; if(num>sum/2){print(i+1); num=0;}
}

n = parseInt(readline());
k = readline().split(" ");
k = k.sort(function(a,b){return b - a});
var jam = 0;
var count = 0;
sum = k.reduce((a, b) => parseInt(a) + parseInt(b)) / 2;
for( var i = 0 ; i < n  ; i++){
	jam = jam + parseInt(k[i]);
	count = count +1 ;
	if(jam > Math.ceil(sum)){break;}
}
print(count);

var s = Number(readline())
var res = 0
var j =readline().split(" ")
var max  = 0

function sortNumber(a,b) {
    return a - b;
}
j.sort(sortNumber);
j.reverse()
print(j)

for (var i = 0; i < s; i++) {

    var ab = j.slice(0, i + 1).reduce((a, b) => Number(a) + Number(b), 0)
    var bb = j.slice(i + 1, s + 1).reduce((a, b) => Number(a) + Number(b), 0)

    if(ab > bb) {
        res = i + 1
        break;
    }
}

print(res)

function main(){
    var n = +readline();
    var ms = readline().split(' ').sort((a,b) => +b - +a);
    var sum = ms.reduce((acc, ac) => acc + +ac, 0);
    var med = sum / 2;
    var res = 0;
    for(var i = 0; i < n; ++i){
        res += ms[i];
        if(res > med){
            break;
        }
    }
    print(i + 1);
}

main();

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }

    sum += parseInt(dataMas[i]);
}

for (var i = 0, length = dataMas.length; !flag; i++) {
    if (sum2 <= sum ) {
        answer = answer + 1;
    }
    else {
        answer = answer + 1;
        flag = true;
    }

    sum2 += parseInt(dataMas[i]);
    sum  -= parseInt(dataMas[i]);
}

write(answer);

var n = Number(readline());
var amt = readline().split(' ').map((cur) => Number(cur));
var max = 0;
var sum = amt.reduce((acc, c) => {
    return acc + c
},0);
var count = 0;

while(max <= sum){
count++;
max = max + Math.max(...amt);
amt.splice(amt.indexOf(max),1);
sum = amt.reduce((acc, c) => {
    return acc + c;

} ,0);
}

print(count);

var numberOfCoin  = 5,
    temp = "2 2 2 2 4",
    sum = 0 ,
    coins = temp.split(" ").sort(),
    counter=coins[numberOfCoin-1];
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
var i = numberOfCoin -1;
    if(counter <= Math.ceil(sum/2)){
        counter+=coins[i-1];
        print(counter);
    }
    else{
        print(numberOfCoin-i);
    }

var dataCount = parseInt(readline()),
    dataMas   = readline().split(" "),
    flag      = false,
    answer    = 0, sum = 0, sum2 = 0;

// Сортируем в порядке возрастания
for (var i = 0, length = dataMas.length - 1; i < length; i++) {
    for (var j = i+1; j < dataMas.length; j++) {
        if (dataMas[i] < dataMas[j]) {
            var current = dataMas[i];
            dataMas[i] = dataMas[j];
            dataMas[j] = current;
        }
    }
}

for (var i = 0, length = dataMas.length - 1; flag!==true; i++) {
    sum += i;
    sum2 = 0;

    for (var j = i; i < length; i++) {
        sum2 += dataMas[j];
    }

    if (sum > sum2) {
        answer += 1;
        flag = true;
    }
}

write(answer);

var num = readline();
var coins = readline().split(" ");
var total = 0;
coins.sort(function(a, b) {
  return a - b;
});

for(var i = 0; i <= coins.length; i++){
    total = total + parseInt(coins[i]);
}

print(total);

function readn() {
	return +readline();
}
function readns() {
	return readline().split(" ").map(function(x) { return +x; });
}

var n = readn();
var a = readns();

a = a.sort().reverse();

var fullSum = a.reduce(function(prev, current){
	return prev+current;
});

var sum1 = 0;
for (var i = 0; i < a.length; i++) {
	sum1 += a[i];
	if (sum1 > fullSum/2 + 1e-9) {
		print(i);
		break;
	}
}

function readn() {
	return +readline();
}
function readns() {
	return readline().split(" ").map(function(x) { return +x; });
}

var n = readn();
var a = readns();

a = a.sort().reverse();

var fullSum = a.reduce(function(prev, current){
	return prev+current;
});

if (a[0] === 10) {
print(999);
}
var sum1 = 0;
for (var i = 0; i < a.length; i++) {
	sum1 += a[i];
	if (sum1 > fullSum/2 + 1e-6) {
		print(i+1);
		break;
	}
}

var numberOfCoin  = +readline(),
    coins = readline().split(" ").sort(),
    sum = 0, counter=0;
for(var i = 0; i < numberOfCoin; i++){
    coins[i]=+coins[i];
    sum+=coins[i];
}
for(var i = numberOfCoin -1; i >=0; i--){
    if(counter <= Math.ceil(sum/2)){
        print(i);
    }
}

var n = readline();
var c = readline().split(" ").sort(function(a, b) {
  return a - b;
});
c.reverse();
var f = 0;
var sum1=0;
var sum2=0;
var s=0;
for (i=0;i<c.length;i++)
sum2=sum2+c[i];
while (f===0)
{
    if (sum2>sum1)
    {
    sum2=sum2-c[s];
    sum1=sum1+c[s];
    s++;
    }
    else f=1;
}
print(s);


Last summer, Feluda gifted Lalmohan-Babu a balanced bracket sequence $$$s$$$ of length $$$2 n$$$.Topshe was bored during his summer vacations, and hence he decided to draw an undirected graph of $$$2 n$$$ vertices using the balanced bracket sequence $$$s$$$. For any two distinct vertices $$$i$$$ and $$$j$$$ ($$$1 \le i < j \le 2 n$$$), Topshe draws an edge (undirected and unweighted) between these two nodes if and only if the subsegment $$$s[i \ldots j]$$$ forms a balanced bracket sequence.Determine the number of connected components in Topshe's graph.See the Notes section for definitions of the underlined terms.

Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of opening brackets in string $$$s$$$. The second line of each test case contains a string $$$s$$$ of length $$$2 n$$$ — a balanced bracket sequence consisting of $$$n$$$ opening brackets "(", and $$$n$$$ closing brackets ")". It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, output a single integer — the number of connected components in Topshe's graph.

NoteSample explanation:In the first test case, the graph constructed from the bracket sequence (), is just a graph containing nodes $$$1$$$ and $$$2$$$ connected by a single edge. In the second test case, the graph constructed from the bracket sequence ()(()) would be the following (containing two connected components):  Definition of Underlined Terms: A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters $$$+$$$ and $$$1$$$. For example, sequences (())(), (), and (()(())) are balanced, while )(, ((), and (()))( are not. The subsegment $$$s[l \ldots r]$$$ denotes the sequence $$$[s_l, s_{l + 1}, \ldots, s_r]$$$. A connected component is a set of vertices $$$X$$$ such that for every two vertices from this set there exists at least one path in the graph connecting these vertices, but adding any other vertex to $$$X$$$ violates this rule.

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}

function stringArr1() {
  return readline().trim().split(" ");
}
function getValue() {
  return parseInt(readline());
}
let mod = 1e9 + 7;
mod = BigInt(mod);
const pow = (num, exp, mod) => {
  if (exp === BigInt(0)) return BigInt(1);
  let x = pow(num, exp / BigInt(2), mod);
  if (exp % BigInt(2)) return (((x * x) % mod) * num) % mod;
  else return (x * x) % mod;
};
const inverse = (num, exp) => {
  return pow(BigInt(num), BigInt(exp), BigInt(mod));
};
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let arr = stringArr();
    let cnt = 0,
      ans = 1,
      prev;
    for (let i = 0; i < arr.length; i++) {
      if (arr[i] === "(") {
        if (cnt === 0) cnt++;
        else if (cnt !== 0 && prev === ")") cnt++;
        else {
          cnt++;
          ans++;
        }
      } else {
        cnt--;
      }
      prev = arr[i];
    }
    console.log(ans);
  }
};
solve();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rn = async () => Number(await read());
  const n = await rn();
  const s = await read();
  const N = 2 * n;
  const p = [...new Array(N).keys()];
  const find = i => i === p[i] ? i : p[i] = find(p[i]);
  const union = (i, j) => {
    const ri = find(i),
          rj = find(j);
    if (ri !== rj) p[rj] = ri;
  };
  const stack = [];
  for (let i = 0; i < N; i++) {
    if (s[i] === '(') {
      stack.push(i);
    } else if (s[i] === ')') {
      let j = stack.pop();
      union(j, i);
      if (j + 1 < i - 1) union(j + 1, i - 1);
      if (!stack.length) union(0, i);else {
        const j = stack[stack.length - 1] + 1;
        union(j, i);
      }
    }
  }
  const root = new Set();
  for (let i = 0; i < N; i++) {
    root.add(find(i));
  }
  return root.size;
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();

;
var inp = [];
var out = [];
var lines;
var lineCounter = 0;
var readline = function () { return lines[lineCounter++]; };
var writeline = function (line) { return out.push(String(line)); };
process.stdin.on('data', function (c) { return inp.push(c); });
process.stdin.on('end', function () {
    lines = inp.join('').split('\n');
    myMain();
    console.log(out.join('\n'));
});
var DSU = /** @class */ (function () {
    function DSU(sz) {
        this.par = Array.from({ length: sz }, function (id) { return -1; });
        this.compCnt = sz;
    }
    DSU.prototype.findset = function (u) {
        var p = u;
        while (this.par[p] >= 0) {
            p = this.par[p];
        }
        while (this.par[u] >= 0) {
            var tmp = this.par[u];
            this.par[u] = p;
            u = tmp;
        }
        return p;
    };
    DSU.prototype.join = function (u, v) {
        var _a;
        u = this.findset(u);
        v = this.findset(v);
        if (u === v)
            return;
        if (-this.par[u] < -this.par[v]) {
            _a = [v, u], u = _a[0], v = _a[1];
        }
        this.par[u] += this.par[v];
        this.par[v] = u;
        --this.compCnt;
    };
    return DSU;
}());
function myMain() {
    var ntest = +readline();
    for (var testcase = 0; testcase < ntest; ++testcase) {
        var n = +readline();
        var s = readline().trim();
        var dsu = new DSU(2 * n);
        var stk = [];
        for (var i = 0; i < 2 * n; ++i) {
            if (s[i] === '(') {
                stk.push(i);
            }
            else {
                dsu.join(stk.pop(), i);
                if (i + 1 < 2 * n && s[i + 1] === '(') {
                    dsu.join(i, i + 1);
                }
            }
        }
        writeline(dsu.compCnt);
    }
}

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
     let t = parseInt(readline());
     while(t--){
          let n = parseInt(readline());
          let arr = readline().trim().split("");
          let v = {},o = 0,c = 0;
          for(let i=0;i<arr.length;i++){
               if(arr[i]==="(") o++;
               else c++;
               if(o===c) v[i] = 1;
          }
          let cnt = 1;
          for(let i=0;i<arr.length;i++){
               if(arr[i]===")" && v[i]!==1) cnt++;
          }
          console.log(cnt);
     }
};
solve();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rn = async () => Number(await read());
  const n = await rn();
  const s = await read();
  const N = 2 * n;
  const stack = [];
  const p = [...new Array(N).keys()];
  const find = i => i === p[i] ? i : p[i] = find(p[i]);
  const union = (i, j) => {
    const ri = find(i),
          rj = find(j);
    if (ri !== rj) p[rj] = ri;
  };
  for (let i = 0; i < s.length; i++) {
    if (s[i] === '(') {
      stack.push(i);
    } else if (s[i] === ')') {
      let j = stack.pop();
      union(j, i);
      if (j + 1 < i - 1) union(j + 1, i - 1);
      if (!stack.length) union(0, i);
    }
  }
  const root = new Set();
  for (let i = 0; i < N; i++) {
    root.add(find(i));
  }
  return root.size;
}

async function main(r) {
  try {
    let t = Number(await r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();