Problem:
Score : 400 points

Problem Statement

Snuke found N strange creatures.
Each creature has a fixed color and size. The color and size of the i-th creature are represented by i and A_i, respectively.

Every creature can absorb another creature whose size is at most twice the size of itself.
When a creature of size A and color B absorbs another creature of size C and color D (C \leq 2 \times A), they will merge into one creature of size A+C and color B.
Here, depending on the sizes of two creatures, it is possible that both of them can absorb the other.

Snuke has been watching these creatures merge over and over and ultimately become one creature.
Find the number of the possible colors of this creature.

Constraints

2 \leq N \leq 100000

1 \leq A_i \leq 10^9

A_i is an integer.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 … A_N

Output

Print the number of the possible colors of the last remaining creature after the N creatures repeatedly merge and ultimately become one creature.

Sample Input 1

3
3 1 4

Sample Output 1

2

The possible colors of the last remaining creature are colors 1 and 3.
For example, when the creature of color 3 absorbs the creature of color 2, then the creature of color 1 absorbs the creature of color 3, the color of the last remaining creature will be color 1.

Sample Input 2

5
1 1 1 1 1

Sample Output 2

5

There may be multiple creatures of the same size.

Sample Input 3

6
40 1 30 2 7 20

Sample Output 3

4

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
// #include <fstream>//ifstream/ofstream
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <list>
#include <new>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME7_SHORT 10007
#define PRIME9_SHORT 10009
#define PRIME7 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

const bool debug = false;

template<typename T> void rar(size_t n, T* a);
template<typename T> void rar2(size_t n, size_t m, T** a);

template<typename T> T ipow(T base, T exp);

size_t left(size_t current, bool swap = false);
size_t right(size_t current, bool swap = false);

template<typename T> T griddist(T x, T y, T s, T t);
template<typename T> T griddist(pair<T, T> one, pair<T, T> two);
template<typename T> T griddist(tuple<T, T> one, tuple<T, T> two);

template<typename T> T sqeucldist(T x, T y, T s, T t);
template<typename T> T sqeucldist(pair<T, T> one, pair<T, T> two);
template<typename T> T sqeucldist(tuple<T, T> one, tuple<T, T> two);

ull modadd(ull a, ull b, int mod);
ull modmult(ull a, ull b, int mod);

int main(void)
{
    size_t n;
    cin >> n;
    vector<ull> a;
    for (size_t i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }

    sort(a.begin(), a.end());

    ull streak = 0UL;
    ull sum = 0UL;
    for (size_t i = 0; i < n; ++i) {
        sum += a[i];
        ull next = a[i+1];
        // cout << i << ' ' << sum << ' '  << next << ' ' << streak << ' ' << endl;
        if (next <= 2*sum) {
            ++streak;
        } else {
            streak = 0UL;
        }
    }

    cout << streak << endl;
    return 0;
}

template<typename T>
void rar(size_t n, T* a) {
    for (size_t i = 0; i < n; ++i) cin >> a[i];
    return;
}

template<typename T>
void rar2(size_t n, size_t m, T** a) {
    for (size_t i = 0; i < n; ++i) {
        a[i] = new int[m];
        for (size_t j = 0; j < m; ++j) cin >> a[i][j];
    } return;
}

template<typename T>
T ipow(T base, T exp) {
    T result = 1;
    // Maybe add inverse functionality
    // if (exp < 0) {
    //     exp = -exp;
    //     // Doesn't really work since T integral
    //     base = 1./base;
    // }
    while (exp) {
        if (exp & 1) result *= base;
        exp >>= 1;
        base *= base;
    }
    return result;
}

size_t left(size_t current, bool swap) {
    return swap ? right(current, false) : 2*current+1;
}
size_t right(size_t current, bool swap) {
    return swap ? left(current, false) : 2*(current+1);
}

template<typename T>
T griddist(T x, T y, T s, T t) {
    return abs(x-s) + abs(y-t);
}
template<typename T>
T griddist(pair<T, T> one, pair<T, T> two) {
    return abs(one.first - two.first) + abs(one.second - two.second);
}
template<typename T>
T griddist(tuple<T, T> one, tuple<T, T> two) {
    return abs(get<0>(one) - get<0>(two)) + abs(get<1>(one) - get<1>(two));
}

template<typename T>
T sqeucldist(T x, T y, T s, T t) {
    T a = x-s;
    T b = y-t;
    return a*a+b*b;
}
template<typename T>
T sqeucldist(pair<T, T> one, pair<T, T> two) {
    T a = one.first - two.first;
    T b = one.second - two.second;
    return a*a+b*b;
}
template<typename T>
T sqeucldist(tuple<T, T> one, tuple<T, T> two) {
    T a = get<0>(one) - get<0>(two);
    T b = get<1>(one) - get<1>(two);
    return a*a+b*b;
}

ull modadd(ull a, ull b, int mod) {
    return ((a%mod) + (b%mod))%mod;
}
ull modmult(ull a, ull b, int mod) {
    return ((a%mod)*(b%mod))%mod;
}