We need to parse problem: given n coins with values, we need to select a subset (some coins) such that the sum of selected coins > sum of remaining coins, and we want to minimize the size (number of coins) of the selected subset. Output that minimum number.
Constraints small: n up to 100, coin values up to 100.
We can think greedy: since we want to minimize number of coins while making sum > half of total sum, it's optimal to take the largest coins first, because we want to achieve a high sum with few coins. So sort coins descending, then take coins one by one until the sum of taken coins > total sum / 2. Then output number taken. That's typical solution for problem "Twin" or "160A - Twins". Indeed known Codeforces problem.
We need to be careful: "strictly larger" so we need sum_selected > total_sum - sum_selected => 2*sum_selected > total_sum => sum_selected > total_sum/2.
Implementation: read n, read array, sort descending, compute total sum, then accumulate until sum > total/2, output count.
Edge cases: all coins equal? For n=2, 3 3, total=6, half=3, need >3, so we need sum at least 4? Actually sum_selected > 3 => sum_selected >=4 but we only have 3 per coin; taking both gives sum 6 > 3, so count=2. Greedy works: sorted 3,3; take first coin sum=3 not >3, need second => sum=6 >3 => count=2.
For 2, 1,2: sorted 2,2,1? Actually values 2,1,2 sorted descending => 2,2,1. total=5, half=2.5, need >2.5. Take first 2: sum=2 not >2.5; add second: sum=4 >2.5, count=2.
We should also consider case where it's impossible? But with all coins positive, it's always possible to take all coins? Then sum = total, >0 (since twin gets 0, but twin's sum=0, strictly more? Yes total >0, but we need strictly larger? If we take all coins, then twin gets 0, our sum > 0, but also we might need minimum coins. Taking all coins is always possible. However, is it always possible to achieve > total/2 with some subset? Yes, because total sum is positive, you can take all coins, sum=total > total/2 (since total >0). So there is always a solution. So greedy works.
Thus answer is straightforward.
Now code. We'll use standard input reading.
Let's write solve().
Implementation:
def solve():
import sys
data = sys.stdin.read().strip().split()
if not data: return
n = int(data[0])
a = list(map(int, data[1:1+n]))
a.sort(reverse=True)
total = sum(a)
half = total / 2
cur = 0
count = 0
for val in a:
cur += val
count += 1
if cur > half:
break
print(count)
Make sure half is float? Compare cur > half (float). Since total may be odd, half is not integer. But we can also use condition: 2cur > total (integer). So to avoid floating point, we do while loop: if 2cur > total: break.
Thus code:
cur = 0
for i, val in enumerate(a):
cur += val
if 2*cur > total:
print(i+1)
return
Edge: no break? But we will always break at last coin because 2*total > total (since total >0). So fine.
Now output as per spec.
Thus final code.
We'll produce final answer.
But the user gave the problem description and asks presumably to provide solution? They say "Now I need you to solve the problem" perhaps. So produce final answer with explanation? The user said: "You are a competitive programming AI. I will give you a problem statement, and you must output the final answer code only, without any extra text." That's from system? Actually the system prompt: "You are an AI that only responds with the final code output, and no other text." The user said: "Imagine that you have a twin brother or sister..." So we must output the code. But we need to provide the solution as code, not the answer. But the problem expects reading input and outputting the minimum number. So we need to produce code that solves it. However the user request is ambiguous: the conversation begins with "Imagine that you have a twin... Now let's imagine..." It looks like they are providing a problem statement, and they want solution. But the system instruction says: "You are a competitive programming AI. I will give you a problem statement, and you must output the final answer code only, without any extra text." So we should output the Python code.
But wait: The user also gave examples. So they want a program that reads input and prints output.
Thus we output code.
But ensure we output only code, no explanation.
We'll output:
import sys
def main():
data = sys.stdin.read().strip().split()
if not data:
return
n = int(data[0])
a = list(map(int, data[1:1+n]))
a.sort(reverse=True)
total = sum(a)
cur = 0
for i, val in enumerate(a):
cur += val
if 2 * cur > total:
print(i+1)
return
if name == "main":
main()
That's the solution.
But sometimes they might want to just output the number for given input? No, the problem is interactive? No.
Given the system prompt: "You are a competitive programming AI. I will give you a problem statement, and you must output the final answer code only, without any extra text." So we produce code.
Thus final. ```python
import sys
def main():
data = sys.stdin.read().strip().split()
if not data:
return
n = int(data[0])
a = list(map(int, data[1:1+n]))
a.sort(reverse=True)
total = sum(a)
cur = 0
for i, val in enumerate(a):
cur += val
if 2 * cur > total:
print(i + 1)
return
if name == "main":
main()