codeparrot/codecomplex huggingface dataset:
// Problem: 160_A. Twins
// Time complexity: nlogn
//Edwin Lunando template for online algorithm contest
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main {

//  class node implements Comparable<node> {
//
//    public int a;
//    public int b;
//
//    public int compareTo(node a) {
//      if (a.b == this.b) {
//        return a.a - this.a;
//      } else {
//        return a.b - this.b;
//      }
//    }
//
//    public node(int a, int b) {
//      this.a = a;
//      this.b = b;
//    }
//  }

  private void solve() throws IOException {
    int n = nextInt();
    int[] arr = new int[n];
    int count = 0;
    for (int x = 0; x < n; x++) {
      arr[x] = nextInt();
      count+= arr[x];
    }
    Arrays.sort(arr);
    count /=2;
    int result = 0, sum = 0;
    for (int x = arr.length - 1; x >= 0; x--) {
      sum += arr[x];
      result++;
      if (sum > count) {
        break;
      }
    }
    System.out.println(result);
  } 

  public static void main(String[] args) {
    try {
      br = new BufferedReader(new InputStreamReader(System.in));
      //br = new BufferedReader(new FileReader("input.txt"));
      out = new PrintWriter(System.out);
      //out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
      new Main().solve();
      out.close();
    } catch (Throwable e) {
      System.out.println(e);
      System.exit(239);
    }
  }
  static BufferedReader br;
  static StringTokenizer st;
  static PrintWriter out;

  static String nextToken() throws IOException {
    while (st == null || !st.hasMoreTokens()) {
      String line = br.readLine();
      if (line == null) {
        return null;
      }
      st = new StringTokenizer(line);
    }
    return st.nextToken();
  }

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

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

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

  static int[] nextIntArray(int n) throws IOException {
    int[] temp = new int[n];
    for (int x = 0; x < n; x++) {
      temp[x] = nextInt();
    }
    return temp;
  }

  static long[] nextLongArray(int n) throws IOException {
    long[] temp = new long[n];
    for (int x = 0; x < n; x++) {
      temp[x] = nextLong();
    }
    return temp;
  }

  static String[] nextArray(int n) throws IOException {
    String[] temp = new String[n];
    for (int x = 0; x < n; x++) {
      temp[x] = nextToken();
    }
    return temp;
  }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.*;
import java.util.*;

public class A implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    private void solve() {
        int n = in.nextInt();
        int[] a = new int[n];
        int all = 0;
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
            all += a[i];
        }
        Arrays.sort(a);
        int sum = 0, ans = 0;
        for (int i = n - 1; i >= 0; --i) {
            sum += a[i];
            ++ans;
            if (sum > all - sum) {
                break;
            }
        }
        out.println(ans);
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

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

    static class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

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

        public String nextLine() {
            try {
                st = null;
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

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

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

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

        public boolean hasNext() {
            if (st != null && st.hasMoreTokens()) {
                return true;
            }
            try {
                while (br.ready()) {
                    st = new StringTokenizer(br.readLine());
                    if (st != null && st.hasMoreTokens()) {
                        return true;
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            return false;
        }
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.*;
public class codeee {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n==1){System.out.println(1); return;}
        int []mas=new int[n];
        int sum=0;
        for (int i = 0; i < n; i++) {
            mas[i]=sc.nextInt();
            sum+=mas[i];
        }
        Arrays.sort(mas);
        int sum1=0;
        int ans=0;
        for(int i=0;i<n;i++){
            sum1+=mas[n-i-1];
            if(sum1>(sum-sum1)){
                ans=i;
                break;
            }
        }
        System.out.println(ans+1);
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author codeKNIGHT
 */
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(),i,sum=0;
        int a[]=new int[n];
        for(i=0;i<n;i++)  {

            a[i]=in.nextInt();
            sum+=a[i];
        }
        Arrays.sort(a);
        int s=0,c=0;
        for(i=n-1;i>=0;i--)
        {
            if(s>sum)
                break;
            s+=a[i];
            sum-=a[i];
            
                        c++;
        }
        out.println(c);
	}
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main implements Runnable {
    PrintWriter out;
    BufferedReader in;
    StringTokenizer st;
    
    void solve() throws Exception {
        int n = nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i = 0; i < n; ++i) {
            a[i] = nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        int ans = 0, csum = 0;
        for(int i = n - 1; csum <= sum - csum && i >= 0; i--) {
            csum += a[i];
            ans++;
        }
        out.println(ans);
    }

    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//          in = new BufferedReader(new FileReader("input.txt"));
//          out = new PrintWriter("output.txt");
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    static public void main(String args[]) throws Exception {
        (new Main()).run();
    }
    
    int nextInt() {
        return Integer.parseInt(nextToken());
    }
    
    double nextDouble() {
        return Double.parseDouble(nextToken());
    }
    
    String nextToken() {
        while(st == null || !st.hasMoreTokens()) {
            try {
                String line = in.readLine();
                st = new StringTokenizer(line);
            } catch(Exception e) {
                return null;
            }
        }
        return st.nextToken();
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.*;
public class Solution {
    public static void main(String [] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int [] a = new int [n];
        int i;
        int s = 0;
        for (i = 0; i < n; i++) {
            a[i] = scan.nextInt();
            s += a[i];
        }
        Arrays.sort(a);
        int sum = 0;
        for (i = n - 1; i > -1; i--) {
            sum += a[i];
            if (s - sum < sum) {
                System.out.println(n - i);
                return;
            }
        }
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
 import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

    public class Test {
            static BufferedReader reader;
            static StringTokenizer tokenizer;
            static PrintWriter writer;

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

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

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

            static String nextToken() throws IOException {
                    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                            tokenizer = new StringTokenizer(reader.readLine());
                    }
                    return tokenizer.nextToken();
            }

            public static void main(String[] args) throws IOException {
                    reader = new BufferedReader(new InputStreamReader(System.in));
                    tokenizer = null;
                    writer = new PrintWriter(System.out);
                    solve();
                    reader.close();
                    writer.close();
            }

            private static void solve() throws IOException {
                int n=nextInt();
                int[] a=new int[n];
                int first=0;
                for (int i=0;i<n;i++)
                {
                    a[i]=nextInt();
                    first+=a[i];
                }
                Arrays.sort(a);
                int ans=1;
                int last=a[n-1];
                first-=a[n-ans];
                while (true)
                {
                    if (first<last)
                        break;
                    ans++;
                    last+=a[n-ans];
                    first-=a[n-ans];
                }
                writer.print(ans);
            }


    }
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Round111A {

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

    public void run() throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Scanner scanner = new Scanner(reader);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int sum = 0;
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            sum += a[i];
        }
        Arrays.sort(a, Collections.reverseOrder());

        int s = 0;
        int i = 0;
        while (i < n && (s <= sum / 2)) {
            s += a[i];
            i++;
        }

        writer.print(i);

        scanner.close();
        writer.close();
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class C111A{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));
        int n = toInt();
        int nm[] = toIntArray();
        double a=0.0;
        double sum=0;
        for(int i=0;i<n;i++){
            sum+=nm[i];
        }
        a=sum/2;
        Arrays.sort(nm);
        int cur=0;
        int count=0;
        for(int i=nm.length-1;i>=0;i--){
            cur+=nm[i];
            count++;
            if(cur>a){
                break;
            }
        }
        System.out.println(count);


    }


    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

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

public class A {

	public A () throws IOException {
		int N = sc.nextInt();
		int [] A = new int [N];
		for (int n = 0; n < N; ++n)
			A[n] = sc.nextInt();
		solve(N, A);
	}
	
	public void solve (int N, int [] A) {
		//start();
		Arrays.sort(A);
		int S1 = 0;
		for (int n = 0; n < N; ++n)
			S1 += A[n];
		
		int S2 = 0;
		for (int n = N - 1; n >= 0; --n) {
			S2 += A[n];
			if (S2 > S1 - S2)
				exit(N - n);
		}
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	static MyScanner sc;
	static long t;
	
	static void print (Object o) {
		System.out.println(o);
	}
	
	static void exit (Object o) {
		print(o);
		//print2((millis() - t) / 1000.0);
		System.exit(0);
	}
	
	static void run () throws IOException {
		sc = new MyScanner ();
		new A();
	}
	
	public static void main(String[] args) throws IOException {
		run();
	}
	
	static long millis() {
		return System.currentTimeMillis();
	}
	
	static void start() {
		t = millis();
	}
	
	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}
		
		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		
		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}

		//////////////////////////////////////////////
		
		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}
		
		MyScanner(BufferedReader r) throws IOException { 
			this.r = r;
			newLine();
		}
		
		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || index == line.length) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}		
	}	
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException, IOException {
        Solver solver = new Solver();
        solver.open();
        solver.solve();
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

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

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

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

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();
        
        int[] ar = new int[n];
        int sum = 0;
        
        for (int i=0;i<n;i++){
            ar[i]=nextInt();
            sum+=ar[i];            
        }
        
        Arrays.sort(ar);
        
        int me = 0;
        int k = 0;
        while (me<=sum){
            k++;
            int coin = ar[ar.length-k];
            me += coin;
            sum -= coin;
        }
        
        out.println(k);
    }

    public void close() {
        out.flush();
        out.close();
    }

}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class con111_A {

    public static void main( final String[] args ) throws IOException {
        final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        final int n = Integer.parseInt( br.readLine() );
        final int[] a = new int[n];
        final String[] parts = br.readLine().split( " " );
        for ( int i = 0; i < n; ++i ) {
            a[ i ] = Integer.parseInt( parts[ i ] );
        }
        System.out.println( solve( n, a ) );
    }

    private static int solve( final int n, final int[] a ) {
        Arrays.sort( a );
        int sum = 0;
        for ( int i = 0; i < n; ++i ) {
            sum += a[ i ];
        }
        int res = 0;
        int ms = 0;
        for ( int i = n - 1; i >= 0; --i ) {
            if ( ms > sum / 2 ) {
                break;
            } else {
                ms += a[ i ];
                ++res;
            }
        }
        return res;
    }

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

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


public class Round111ProbA {

    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        int n = in.nextInt();
        int[]a = new int[n];
        int s =0;
        for(int i =0 ; i < n;i++)
        {
            a[i] = in.nextInt();
            s += a[i];
        }
        Arrays.sort(a);
        int x =0;
        int c =0;
        for(int i =n-1 ; i >-1;i-- )
        {
            x +=a[i];
            s -= a[i];
            c++;
            if(x > s)break;
        }
        System.out.println(c);
    }
    
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.io.*;
import java.util.*;
import java.lang.Math.*;
public class A111
{
     public static void main(String args[])throws Exception
     {
         Scanner in=new Scanner(System.in);
         // br=new BufferedReader(new InputStreamReader(System.in));
         PrintWriter pw=new PrintWriter(System.out);
         int n,i,j,k=0,l;
         n=in.nextInt();
         int a[]=new int[n];
         int sum=0,sum1=0;
         for(i=0;i<n;i++)
         {
            a[i]=in.nextInt(); 
            sum+=a[i];
            }
            Arrays.sort(a);
         for(j=n-1;j>=0;j--)
         {
             sum1+=a[j];
             k++;
             if(sum1*2>sum)
             break;
            }
            pw.println(k);
         pw.flush();
     }
}
// Problem: 160_A. Twins
// Time complexity: nlogn

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

public class round111A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] coins = new int [n];
        for(int i = 0 ; i < n ; ++i)
            coins[i] = sc.nextInt();
        Arrays.sort(coins);
        int ans = (int)1e9;
        for(int i = 1 ; i <= n ; ++i){
            int sum1 = 0;
            int c = 0;
            int j = n - 1;
            for(j = n - 1 ; j >= 0 && c < i ; --j, ++c){
                sum1 += coins[j];
            }
            int sum2 = 0;
            for(int k = 0 ; k <= j ; ++k)
                sum2 += coins[k];
            if(sum1 > sum2){
                System.out.println(i);
                return;
            }
        }
    }
}
// Problem: 160_A. Twins
// Time complexity: nlogn
import java.util.*;

public class TaskA {

    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        Arrays.sort(a);

        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }

        int take = 0, num = 0;

        for (int i = n - 1; i > -1; i--) {
            num++;
            take += a[i];
            sum -= a[i];
            if (take > sum) {
                break;
            }
        }

        System.out.println(num);
    }
}