#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int t, i, sum = 0, ans = 0, j = 0;
  scanf("%d", &t);
  int a[t];
  for (i = 0; i < t; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  sum /= 2;
  quick_sort(a, 0, t - 1);
  for (i = t - 1; i >= 0; i--) {
    ans += a[i];
    if (ans > sum) {
      printf("%d\n", ++j);
      break;
    }
    j++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xea5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d8 <main+0xa8>
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4c(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <main+0x62>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <quick_sort@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1258 <main+0x128>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    1241 <main+0x111>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
lea    0xdcc(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <main+0x128>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1200 <main+0xd0>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%edx
test   %edx,%edx
jle    11c2 <main+0x92>
mov    %r12,-0x38(%rbp)
xor    %r12d,%r12d
lea    0xe7f(%rip),%r15
mov    %r14,%rbx
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    (%rbx),%r13d
add    $0x1,%r12
movslq -0x2c(%rbp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r12
jl     1190 <main+0x60>
mov    %r13d,%r15d
shr    $0x1f,%r15d
add    %r13d,%r15d
sar    %r15d
mov    -0x38(%rbp),%r12
jmp    11c5 <main+0x95>
xor    %r15d,%r15d
add    $0xffffffff,%edx
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <quick_sort@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    1215 <main+0xe5>
add    $0xffffffffffffffff,%rax
mov    $0x1,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%ecx
add    (%r14,%rcx,4),%ebx
cmp    %r15d,%ebx
jg     1209 <main+0xd9>
add    $0x1,%esi
add    $0xffffffffffffffff,%rax
cmp    $0xffffffff,%eax
jne    11f0 <main+0xc0>
jmp    1215 <main+0xe5>
lea    0xdf3(%rip),%rdi
call   1030 <printf@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i32, i64 %11
store i64 %11, i64* %8
store i32 0, i32* %3
br label %14
14: ; preds = %29, %0
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %13, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %13, i64 %24
%26 = load i32, i32* %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, %26
store i32 %28, i32* %4
br label %29
29: ; preds = %18
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %14
32: ; preds = %14
%33 = load i32, i32* %4
%34 = sdiv i32 %33, 2
store i32 %34, i32* %4
%35 = load i32, i32* %2
%36 = sub nsw i32 %35, 1
%37 = call i32 @quick_sort(i32* %13, i32 0, i32 %36)
%38 = load i32, i32* %2
%39 = sub nsw i32 %38, 1
store i32 %39, i32* %3
br label %40
40: ; preds = %60, %32
%41 = load i32, i32* %3
%42 = icmp sge i32 %41, 0
br i1 %42, label %43, label %63
43: ; preds = %40
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %13, i64 %45
%47 = load i32, i32* %46
%48 = load i32, i32* %5
%49 = add nsw i32 %48, %47
store i32 %49, i32* %5
%50 = load i32, i32* %5
%51 = load i32, i32* %4
%52 = icmp sgt i32 %50, %51
br i1 %52, label %53, label %57
53: ; preds = %43
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %55)
br label %63
57: ; preds = %43
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %60
60: ; preds = %57
%61 = load i32, i32* %3
%62 = add nsw i32 %61, -1
store i32 %62, i32* %3
br label %40
63: ; preds = %53, %40
store i32 0, i32* %1
%64 = load i8*, i8** %7
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = alloca i32, i64 %5
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %0, %10
%11 = phi i64 [ %17, %10 ], [ 0, %0 ]
%12 = phi i32 [ %16, %10 ], [ 0, %0 ]
%13 = getelementptr inbounds i32, i32* %7, i64 %11
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = load i32, i32* %13
%16 = add nsw i32 %15, %12
%17 = add nuw nsw i64 %11, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %10, label %21
21: ; preds = %10
%22 = sdiv i32 %16, 2
br label %23
23: ; preds = %21, %0
%24 = phi i32 [ 0, %0 ], [ %22, %21 ]
%25 = phi i32 [ %8, %0 ], [ %18, %21 ]
%26 = add nsw i32 %25, -1
%27 = call i32 @quick_sort(i32* %7, i32 0, i32 %26)
%28 = load i32, i32* %1
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %47
30: ; preds = %23
%31 = zext i32 %28 to i64
br label %32
32: ; preds = %30, %44
%33 = phi i64 [ %31, %30 ], [ %36, %44 ]
%34 = phi i32 [ 1, %30 ], [ %45, %44 ]
%35 = phi i32 [ 0, %30 ], [ %40, %44 ]
%36 = add nsw i64 %33, -1
%37 = and i64 %36, 4294967295
%38 = getelementptr inbounds i32, i32* %7, i64 %37
%39 = load i32, i32* %38
%40 = add nsw i32 %39, %35
%41 = icmp sgt i32 %40, %24
br i1 %41, label %42, label %44
42: ; preds = %32
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %47
44: ; preds = %32
%45 = add nuw i32 %34, 1
%46 = icmp eq i32 %34, %28
br i1 %46, label %47, label %32
47: ; preds = %44, %23, %42
ret i32 0
}