codeparrot/codecomplex huggingface dataset:
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.*;
import java.security.SecureRandom;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
    
    
    
    
    public void solve() throws Exception {
        int n = sc.nextInt();
        int a[] = new int[n];
        int s = 0;
        for (int i = 0;i < n; ++ i) {
            a[i] = sc.nextInt();
            s += a[i];
        }
        Arrays.sort(a);
        int s2 = 0;
        for (int i = n - 1;i >= 0; -- i) {
            s2 += a[i];
            if (s2 > s - s2) {
                out.println(n - i);
                break;
            }
        }
        
    }
    
    class Pair implements Comparable<Pair> {
        
        int x;
        int y;
        
        public Pair() {
            
        }
        
        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Pair arg0) {
            if (x == arg0.x)
                return y - arg0.y;
            return x - arg0.x;
        }
    }
    
    
    
    
    /*--------------------------------------------------------------*/
    
    static String filename = "";
    static boolean fromFile = false;
    
    BufferedReader in;
    PrintWriter out;
    FastScanner sc;
    
    public static void main(String[] args) {
        new Thread(null, new Solution(), "", 1 << 25).start();
    }
   
    public void run() {
        try {
            init();
            solve();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }
    
    void init() throws Exception {
        if (fromFile) {
            in = new BufferedReader(new FileReader(filename+".in"));
            out = new PrintWriter(new FileWriter(filename+".out"));
        } else {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
        sc = new FastScanner(in);
    }
}

class FastScanner {
    
    BufferedReader reader;
    StringTokenizer strTok;
    
    public FastScanner(BufferedReader reader) {
        this.reader = reader;
    }
    
    public String nextToken() throws IOException {
        while (strTok == null || !strTok.hasMoreTokens()) {
            strTok = new StringTokenizer(reader.readLine());
        }
        
        return strTok.nextToken();
    }
    
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    
    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }
    
    public BigDecimal nextBigDecimal() throws IOException {
        return new BigDecimal(nextToken());
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author @listen
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int [] input = new int[n];
		int total = 0;
		for (int i = 0; i < n; ++i){
			input[i] = in.nextInt();
			total +=input[i];
		}
		Arrays.sort(input);
		int res = 0;
		int now = 0;
		for (int i = n - 1; i >= 0; --i){
			now += input[i];
			int left = total - now;
			++res;
			if (now > left){
				break;
			}
		}
		out.println(res);
		return;
	}
}
// Problem: 160_A. Twins
// Time complexity: nlogn

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;


public class a implements Comparable<a>{
    
    int x, y, id;
    
    //static BufferedReader in;
    //static StringTokenizer st;
    
    public a(int x1, int y1, int id1){
        this.x = x1; this.y = y1; this.id = id1;
    }
    
    public int compareTo(a o) {
        return x - o.x;
    }
    
    static int n;
    static int arr[];
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //in = new BufferedReader(new InputStreamReader(System.in));
        //st = new StringTokenizer(""," ");
        int n = in.nextInt();
        arr = new int[n];
        int sum = 0;
        for (int i=0; i<n; i++){
            arr[i] = in.nextInt();
            sum +=arr[i];
        }
        Arrays.sort(arr);
        int sum2= 0;
        int ans = 0;
        for (int i=n-1; i>=0; i--){
            sum2+=arr[i];
            //System.out.println(sum2 + " " + sum);
            if (sum2>sum-sum2){
                ans = n - i;
                break;
            }
        }
        System.out.println(ans);
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class SolA {

	static Scanner in;
	static PrintWriter out;

	public static void main(String[] args) {
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);

		new SolA().run();

		in.close();
		out.close();

	}

	private void run() {
		int n = in.nextInt();
		int[] a = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++) {
			a[i] = in.nextInt();
			sum+=a[i];
		}
		Arrays.sort(a);
		int cs = 0;
		int kol = 0;
		for(int i = n - 1; i>=0; i--) {
			cs+=a[i];
			kol++;
			if (cs > sum - cs) {
				break;
			}
		}
		out.print(kol);
	}

}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class A
{
    public A()
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer mas[] = new Integer[n];
        int b = 0;
        for (int i = 0 ; i < n ; i ++)
        {
            mas[i] = sc.nextInt();
            b+=mas[i];
        }
        Arrays.sort(mas, new Comparator<Integer>()
        {

            @Override
            public int compare(Integer o1, Integer o2)
            {
                if(o1>o2)
                    return -1;
                else if(o1==o2)
                    return  0;
                else 
                    return 1;
            }      
        });
        int N = 0; int g = 0;
        for (int i = 0 ; i < n ; i ++)
        {
              g+=mas[i];
              if(g>(int)(b/2))
              {
                  System.out.println(i+1);
                  return;
              }
        }
        System.out.println(n);
    }
    public static void main(String[] args)
    {
        new A();      
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;

public class D {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] p = new int[n];
        for (int i = 0; i < a.length; i++)
            a[i] = p[i] = in.nextInt();
        Arrays.sort(a);

        int sum = 0;
        int t = 0;
        for (int i = 0; i < a.length; i++)
            t += a[i];
        int cnt = 0;
        for (int i = a.length - 1; i >= 0; i--) {
            cnt++;
            sum += a[i];
            if (t - sum < sum)
                break;
        }
        System.out.println(cnt);
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A
{
	String line;
	StringTokenizer inputParser;
	BufferedReader is;
	FileInputStream fstream;
	DataInputStream in;
	String FInput="";
	
	void openInput(String file)
	{

		if(file==null)is = new BufferedReader(new InputStreamReader(System.in));//stdin
		else
		{
			try{
		
				
			fstream = new FileInputStream(file);
			in = new DataInputStream(fstream);
			is = new BufferedReader(new InputStreamReader(in));
			}catch(Exception e)
			{
				System.err.println(e);
			}
		}

	}
	
	void readNextLine()
	{
		try {
			line = is.readLine();
			inputParser = new StringTokenizer(line, " ");
			//System.err.println("Input: " + line);
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}	
		catch (NullPointerException e)
		{
			line=null;
			
		}
		
	}
	
	int NextInt()
	{
		String n = inputParser.nextToken();
		int val = Integer.parseInt(n);
		
		//System.out.println("I read this number: " + val);
		return val;
	}
	
	long NextLong()
	{
		String n = inputParser.nextToken();
		long val = Long.parseLong(n);
		
		//System.out.println("I read this number: " + val);
		return val;
	}
	
	String NextString()
	{
		String n = inputParser.nextToken();
		return n;
	}
	
	void closeInput()
	{
		try {
			is.close();
		} catch (IOException e) {
			System.err.println("Unexpected IO ERROR: " + e);
		}
			
	}
	
	
	public static void main(String [] argv)
	{
		String filePath=null;
		if(argv.length>0)filePath=argv[0];
		new A(filePath);
	}
	
	public void readFInput()
	{
		for(;;)
		{
			try
			{
				readNextLine();
				FInput+=line+" ";
			}
			catch(Exception e)
			{
				break;
			}
		}
		inputParser = new StringTokenizer(FInput, " ");
	}
	 
	public A(String inputFile)
	{
		openInput(inputFile);
		
		readNextLine();
		int n=NextInt();
		
		int ret=0;
		int [] p = new int [n];
		readNextLine();
		int sum=0;
		for(int i=0; i<n; i++)
		{
			int a=NextInt();
			p[i]=a;
			sum+=a;
		}
		Arrays.sort(p);

		int my=0;
	
		for(int i=n-1; i>=0; i--)
		{
			my+=p[i];
			ret++;
			if(my*2>sum)break;
		}
		
		System.out.println(ret);
        closeInput();		
	}

}
// Problem: 160_A. Twins
// Time complexity: nlogn
	import java.util.*;
	public class A {
	public static void main(String args[]){
    Scanner in = new Scanner(System.in);
 int n=in.nextInt(),s=0;
 int[] a= new int[n];
 for (int i=0;i<n;i++) {a[i]=in.nextInt(); s+=a[i];}
 Arrays.sort(a); int k=0,ans=0;
 for (int i=n-1;i>=0;i--)
	 if (k<=s/2) {k+=a[i];ans++;}
 System.out.println(ans);
 
		
	    	}
		}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nova
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        int res = 0;
        int mySum = 0;
        int hisSum = sum;
        for (int i = n - 1; i >= 0; i--) {
            mySum += a[i];
            hisSum -= a[i];
            res++;
            if (mySum > hisSum) break;
        }
        out.println(res);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            writer.print(objects[i]);
        }
    }

    public void println(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
//coded by : ariefianto17 | Reza Ariefianto

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	public static void main (String[]args)
	{
		Scanner read = new Scanner (new BufferedInputStream (System.in));
		int n = read.nextInt();
		int[]arr = new int[n];
		int sum=0;
		int sum2=0;
		int coin=0;
		for(int i=0;i<n;i++)
		{
			arr[i] = read.nextInt();
			sum+=arr[i];
		}
		Arrays.sort(arr);
		for(int i=n-1;i>=0;i--)
		{
			sum2+=arr[i];
			sum-=arr[i];
			coin++;
			if(sum2>sum)
				break;

		}
		System.out.println(coin);
	}
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;


public class solver {
    FastScanner in = new FastScanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    
    
    public static void main(String[] args) {
        new solver().solve();
    }
    
    public void solve() {
    
        int n = in.nextInt();
        int[]tab = new int[n];
        
        int sum = 0;
        
        for (int i = 0; i < n; i++) {
            tab[i] = in.nextInt();
            sum += tab[i];
        }
        
        Arrays.sort(tab);
        int v1 = 0;
        int count = 0;
        
        for (int i = tab.length - 1; i >= 0; i--) {
            v1 += tab[i];
            count++;
            if (v1 > getSum(i, tab)) {
                break;
            }
        }
        
        out.println(count);
        
        in.close();
        out.close();
    }
    
    public int getSum(int index, int[]tab) {
        int sum = 0;
        for (int i = 0; i < index; i++) sum += tab[i];
        return sum;
    }
    
    public int max(int a, int b) {
        if (a > b) return a;
        else return b;
    }
}


class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
    }

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                System.err.println(e);
                return "";
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    float nextFloat() {
        return Float.parseFloat(next());
    }

    BigInteger nextBigInt() {
        return new BigInteger(next());
    }

    void close() {
        try {
            br.close();
        } catch (IOException e) {
        }
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.*;
import java.math.*;
import java.io.*;
public class Main
	{
	public static void main(String args[])	throws IOException
		{
		Scanner c=new Scanner(System.in);
		int N=c.nextInt();
		int A[]=new int[N];
		for(int i=0;i<N;i++) 
			{
			A[i]=c.nextInt();
			}
		Arrays.sort(A);
		int sum=0;
		for(int i=0;i<N;i++) 
			{
			sum+=A[i];
			}
		int my=0;
		int coins=0;
		for(int i=N-1;i>=0;i--) 
			{
			coins++;			//include coin i
			my+=A[i];
			if(my>sum-my)
				{
				System.out.println(coins);
				break;
				}
			}
		}
	}

//must declare new classes here
// Problem: 160_A. Twins
// Time complexity: nlogn

import java.util.Arrays;
import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] A = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            A[i] = in.nextInt();
            sum += A[i];
        }
        Arrays.sort(A);
        int cnt = 0;
        int temp = 0;
        for (int i = n - 1; i >= 0; i--) {
            temp += A[i];
            sum -= A[i];
            cnt++;
            if (temp > sum)
                break;
        }
        System.out.println(cnt);
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.Arrays;
import java.util.Scanner;


public class CF_111_A {

    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), sum = 0, sum2 = 0;
        int[] a = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = in.nextInt();
            sum += a[i];
        }
        
        Arrays.sort(a);
        
        for (int i = n - 1; i >=0; i--){
            sum2 +=a[i];
            if (sum2 * 2 > sum){
                System.out.println(n - 1 - i + 1);
                System.exit(0);             
            }
        }
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;


public class A {

    int n;
    int[] a;
    public void run() throws IOException{
        Scanner s = new Scanner(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        n = s.nextInt();
        a =  new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = s.nextInt();
            sum+=a[i];
        }
        
        Arrays.sort(a);
        
        long mysum = 0;
        int count = 0;
        for (int i = n-1; i > -1; i--) {
            if (mysum > sum)
                break;
            
            count++;
            mysum+=a[i];
            sum-=a[i];
        }
        
        
        System.out.println(count);
        
    }
    
    public static void main(String[] args) throws IOException {
        (new A()).run();
    }

}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;

    void solve() throws IOException {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        
        Arrays.sort(a);
        
        int sum = 0;
        for (int i = 0; i < n; i++)
            sum += a[i];
        
        int cur = 0;
        for (int i = n - 1; i >= 0; i--) {
            cur += a[i];
            if (cur > sum - cur) {
                out.println(n - i);
                return;
            }
        }
    }

    void inp() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new A().inp();
    }

    String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return "0";
            }
        }
        return st.nextToken();
    }

    String nextString() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return "0";
            }
        }
        return st.nextToken("\n");
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

}
// Problem: 160_A. Twins
// Time complexity: nlogn


import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;
	
	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}
	
	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}
	
	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}
	
	long nl() throws IOException 
	{
		return Long.parseLong(ns());
	}
	
	double nd() throws IOException 
	{
		return Double.parseDouble(ns());
	}
		
	String ns() throws IOException 
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens()) 
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}
	
	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}
		
	

	//Main Code starts Here
	int totalCases, testNum;	
	int sum;
	int n;
	int arr[];

	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			if(!input())
				break;
			solve();
		}
	}

	void solve() throws IOException
	{
		Arrays.sort(arr);
		int count = 0;
		int ans = 0;
		for(int i = n-1;i>=0;i--)
		{
			count+= arr[i];
			if(count>sum-count)
			{
				ans = n-i;
				break;
			}
		}
		System.out.println(ans);
	}
	

	boolean input() throws IOException
	{
		n = ni();
		sum = 0;
		arr = new int[n];
		for(int i = 0;i<n;i++)
		{
			arr[i] = ni();
			sum = sum+arr[i];
		}
		return true;
	}


}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.*;

public class A {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) a[i] = s.nextInt();
		int r = 0, an = 0;
		Arrays.sort(a);
		int t = 0;
		for(int z : a) t += z;
		for(int i=a.length-1;i>=0;i--){
			r += a[i];
			an++;
			if (r > t - r) break;
		}
		System.out.println(an);
	}
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution implements Runnable {

	public static void main(String[] args) {
		(new Thread(null, new Solution(), "1", 1l << 28)).start();
	}

	public void run() {
		try {
//			in = new BufferedReader(new FileReader("input.txt"));
//			out = new PrintWriter("output.txt");
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = null;
	
	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			//if (!in.ready()) return null;
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}
	
	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	void solve() throws Exception {
		int n = nextInt();
		int[] a = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) sum += (a[i] = nextInt());
		Arrays.sort(a);
		int ans = 0;
		int s = 0;
		for (int i = n - 1; i >= 0; i--) {
			s += a[i]; ans++;
			if (2 * s > sum) break;
		}
		out.println(ans);
	}
	
}