#include <iostream>

using namespace std;

int main()
{
	int n, sum = 0, boof, l1, l2;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> boof;
		sum += boof;
	}
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> l1 >> l2;
		if (l2 >= sum)
		{
			if (l1 <= sum)
				cout << sum;
			else cout << l1;
			return 0;
		}
	}
	cout << -1;
}


#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	long long int sum = 0;
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum += a;
	}
	int m;
	cin >> m;
	int k;
	int max = 0;
	int boof; int mmax;
	for (int i = 0; i < 2*m; i++)
	{
		boof = k;
		cin >> k;
		if ( k > max ){
		 	max = k;
		 	mmax = boof;
		 }
	}
	if ( sum <= max  && sum >= boof)
	{
		cout << sum;
	} else if (sum <= boof) cout << boof; else cout << -1;
}

/*
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
*/


#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	long long int sum = 0;
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum += a;
	}
	int m;
	cin >> m;
	int k, g;
	int max = 0;
	int boof; int mmax;
	for (int i = 0; i < m; i++)
	{
		cin >> k >> g;
		if ( k > max ){
		 	max = k;
		 	mmax = g;
		 }
	}
	if ( sum <= max && sum >= mmax)
	{
		cout << sum;
	} else if ( sum <= mmax ) cout << mmax; else cout << -1;
}

/*
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
*/


#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	long long int sum = 0;
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum += a;
	}
	int m;
	cin >> m;
	int k;
	int max = 0;
	int boof; int mmax;
	for (int i = 0; i < 2*m; i++)
	{
		boof = k;
		cin >> k;
		if ( k > max ){
		 	max = k;
		 	mmax = boof;
		 }
	}
	if ( sum <= max  && sum >= mmax)
	{
		cout << sum;
	} else if ( sum <= mmax ) cout << mmax; else cout << -1;
}

/*
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
*/


#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	long long int sum = 0;
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum += a;
	}
	int m;
	cin >> m;
	int k;
	int max = 0;
	for (int i = 0; i < 2*m; i++)
	{
		cin >> k;
		if ( k > max ) max = k;
	}
	if ( sum <= max )
	{
		cout << sum;
	} else cout << -1;
}

/*
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
*/


#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	long long int sum = 0;
	int n;
	cin >> n;
	int a;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		sum += a;
	}
	int m;
	cin >> m;
	int k, g;
	int max = 0;
	int boof; int mmax;
	for (int i = 0; i < m; i++)
	{
		cin >> k >> g;
		if ( g > max ){
		 	max = g;
		 	mmax = k;
		 }
	}
	if ( sum <= max && sum >= mmax)
	{
		cout << sum;
	} else if ( sum <= mmax ) cout << mmax; else cout << -1;
}

/*
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
*/


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
typedef long long ll;
ll l[1050], r[1050];
int main(){
	ll sum=0, n, m, b=0, ans=-1;
	scanf("%lld", &n);
	for(ll i=0; i<n; i++){
		ll x;
		scanf("%lld", &x);
		sum+=x;
	}
	scanf("%lld", &m);
	for(ll i=0; i<m; i++){
		scanf("%lld%lld", &l[i], &r[i]);
		if(sum>=l[i]&&sum<=r[i]) ans=sum;
		else if(sum<l[i]) ans=l[i];
	}
	return 0*printf("%lld\n", ans);
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
int l[1050], r[1050];
int main(){
	int n, m, sum=0, b=0;
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int x;
		scanf("%d", &x);
		sum+=x;
	}
	scanf("%d", &m);
	for(int i=0; i<m; i++){
		scanf("%d%d", l+i, r+i);
		if(sum>=l[i]&&sum<=r[i]) b=1;
	}
	if(b) return 0*printf("%d\n", sum);
	else return 0*printf("-1\n");
}


#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
using namespace std;
typedef long long ll;
ll l[1050], r[1050];
int main(){
	ll sum=0, n, m, b=0, ans=-1;
	scanf("%lld", &n);
	for(ll i=0; i<n; i++){
		ll x;
		scanf("%lld", &x);
		sum+=x;
	}
	scanf("%lld", &m);
	for(ll i=0; i<m; i++){
		scanf("%lld%lld", &l[i], &r[i]);
		if(b) continue;
		if(sum>=l[i]&&sum<=r[i]) ans=sum, b=1;
		else if(sum<l[i]) ans=l[i], b=1;
	}
	return 0*printf("%lld\n", ans);
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int a[maxn];
int l[maxn],r[maxn];
int main(void)
{
    int n,m;
    scanf("%d",&n);
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        ans += a[i];
    }
    scanf("%d",&m);
    for(int j=0;j<m;j++)
        scanf("%d %d",&l[j],&r[j]);
    int flag = 0;
    for(int i=0;i<m;i++)
    {
        if(ans>=l[i] && ans<=r[i])
        {
            flag = 1;
            break;
        }
    }
    if(ans>r[m-1])
        puts("-1");
    else if(flag)
        printf("%d\n",ans);
    else
    {
        for(int i=m-1;i>=0;i--)
        {
            if(l[i]<ans)
            {
                flag = 1;
                printf("%d\n",l[i+1]);
                break;
            }
        }
        if(!flag)
            printf("%d\n",l[0]);
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n, m;
    int arr[1005], left[1005], right[1005];
    cin >> n;
    long long res = 0;
    for(int i=0;i <n;++i){
        cin >> arr[i];
        res += arr[i];
    }
    cin >> m;
    int q = 0;
    int flag = 0;
    for(int i=0; i < m; ++i){
        int w;
        cin >> w >> q;
        if(res >= w and res <= q){
            flag = 1;
            res = res;
        }
        else if(res <= w and !flag){
            flag = 2;
            res = w;
        }
    }
    if(q >= res){
        cout << res << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;

}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n, m;
    vector<int> arr(1005), left(1005), right(1005);
    cin >> n;
    int res = 0;
    for(int i=0;i <n;++i){
        cin >> arr[i];
        res += arr[i];
    }
    cin >> m;
    for(int i=0; i < m; ++i){
        cin >> left[i] >> right[i];
    }
    bool flag = false;
    for(int i=0; i < m; ++i){
        if(res >= left[i] and res<=right[i]){
            flag = true;
            break;
        }
    }
    if(res > right[m-1]){
        cout << -1;
    }
    else if(flag){
        cout << res << endl;
    }
    else{
        for(int i=m-1; i >=0;i  = i-1){
            if(left[i]< res){
                flag=true;
                cout << left[i];
                break;
            }
        }
        if(!flag){
            cout << left[0];
        }
    }
    return 0;

}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n, m;
    int arr[1005], left[1005], right[1005];
    cin >> n;
    long long res = 0;
    for(int i=0;i <n;++i){
        cin >> arr[i];
        res += arr[i];
    }
    cin >> m;
    int q = 0;
    int flag = 0;
    for(int i=0; i < m; ++i){
        int w;
        cin >> w >> q;
        if(res >= w and res <= q){
            flag = 1;
            sum = sum;
        }
        else if(sum <= w and !flag){
            flag = 2;
            sum = w;
        }
    }
    if(q >= sum){
        cout << sum << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;

}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n, m;
    vector<int> arr(1005), left(1005), right(1005);
    cin >> n;
    int res = 0;
    for(int i=0;i <n;++i){
        cin >> arr[i];
        res += arr[i];
    }
    cin >> m;
    for(int i=0; i < m; ++i){
        cin >> left[i] >> right[i];
    }
    bool flag = false;
    for(int i=0; i < m; ++i){
        if(res >= left[i] and res<=right[i]){
            flag = true;
            break;
        }
    }
    if(res > right[m-1]){
        cout << -1;
    }
    else if(flag){
        cout << res << endl;
    }
    else{
        for(int i=m-1; i >=0; --i){
            if(left[i]< res){
                flag=true;
                cout << left[i + 1];
                break;
            }
        }
        if(!flag){
            cout << left[0];
        }
    }
    return 0;

}


#include<iostream>

using namespace std;

int main()
{
	int n,m;
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++)
	{	cin>>m; sum+=m;}
	cin>>m;
	int a,b,ch=1;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(sum >= a && sum <=b)
		{	cout<<sum; ch=0; break;}
//		if(sum < a)
//		{	cout<<sum; ch=0; break;}
	}
	if(ch)
		cout<<-1;
}


#include<iostream>

using namespace std;

int main()
{
	int n,m;
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++)
	{	cin>>m; sum+=m;}
	cin>>m;
	int a,b,ch=1;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(sum >= a && sum <=b && ch)
		{	cout<<sum; ch=0; }
		if(sum < a && ch)
		{	cout<<sum; ch=0;}
	}
	if(ch)
		cout<<-1;
}


#include<iostream>

using namespace std;

int main()
{
	int n,m;
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++)
	{	cin>>m; sum+=m;}
	cin>>m;
	int a,b,ch=1;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(sum >= a && sum <=b)
		{	cout<<sum; ch=0; break;}
		if(sum < a)
		{	cout<<sum; ch=0; break;}
	}
	if(ch)
		cout<<-1;
}


#include<iostream>

using namespace std;

int main()
{
	int n,m;
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++)
	{	cin>>m; sum+=m;}
	cin>>m;
	int a,b;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(sum >= a && sum <=b)
		{	cout<<sum; return 0;}
		if(sum < a)
		{	cout<<sum; return 0;}
	}
	cout<<-1;
}


#include<iostream>

using namespace std;

int main()
{
	int n,m;
	cin>>n;
	long long int sum=0;
	for(int i=0;i<n;i++)
	{	cin>>m; sum+=m;}
	cin>>m;
	int a,b,ch=1;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		if(sum >= a && sum <=b && ch)
		{	cout<<sum; ch=0; }
		if(sum < a && ch)
		{	cout<<a; ch=0;}
	}
	if(ch)
		cout<<-1;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll maxn = 5e5;

#define pb push_back
#define ses second.second
#define sef second.first

ll n, m, a[maxn], s = 0, q = 1, l , r;
int main(){
  ios_base :: sync_with_stdio;
  cin.tie(NULL);
  cin >> n ;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    s += a[i];
  }
  cin >> m;
  for(int i = 1; i <= m; i++){
    cin >> l >> r;
    if(sum <= l){
      cout << l ;
      return 0;
    }
    if( sum >= l && sum <= r){
      cout << sum;
      return 0;
    }
  }
  cout << -1;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll maxn = 5e5;

#define pb push_back
#define ses second.second
#define sef second.first

bool cmp(pair < ll , ll > a, pair < ll , ll > b){
  return a.first < b.first;
}

pair < ll , ll > p[maxn];
ll n, m, a[maxn], s = 0, q = 1;
int main(){
  ios_base :: sync_with_stdio;
  cin.tie(NULL);
  cin >> n ;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  s = a[1];
  cin >> m;
  for(int i = 1; i <= m; i++){
    cin >> p[i].first >> p[i].second;
  }
  for(int i = 1; i <= m; i++){
    while(p[i].first > s){
      q++;
      if(q > n){
        cout << p[i].first;
        return 0;
      }
      s += a[q];
    }
    while(p[i].second < s){
      s -= a[q], q--;
      if(q == 0){
        cout << -1;
        return 0;
      }
    }
  }
  cout << s;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll maxn = 5e5;

#define pb push_back
#define ses second.second
#define sef second.first

bool cmp(pair < ll , ll > a, pair < ll , ll > b){
  return a.first < b.first;
}

pair < ll , ll > p[maxn];
ll n, m, a[maxn], s = 0, q = 1;
int main(){
  ios_base :: sync_with_stdio;
  cin.tie(NULL);
  cin >> n ;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  s = a[1];
  cin >> m;
  for(int i = 1; i <= m; i++){
    cin >> p[i].first >> p[i].second;
  }
  for(int i = 1; i <= m; i++){
    while(p[i].first > s){
      q++;
      if(q > n){
        cout << p[i].first;
        return 0;
      }
      s += a[q];
    }
    while(p[i].second < s){
      s -= a[q], q--;
      if(q == 0){
        cout << -1;
        return 0;
      }
    }
  }
  if(q < n){
    cout << -1;
    return 0;
  }
  cout << s;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll maxn = 5e5;

#define pb push_back
#define ses second.second
#define sef second.first

bool cmp(pair < ll , ll > a, pair < ll , ll > b){
  return a.first < b.first;
}

pair < ll , ll > p[maxn];
ll n, m, a[maxn], s = 0, q = 1;
int main(){
  ios_base :: sync_with_stdio;
  cin.tie(NULL);
  cin >> n ;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  s = a[1];
  cin >> m;
  for(int i = 1; i <= m; i++){
    cin >> p[i].first >> p[i].second;
  }
  for(int i = 1; i <= m; i++){
    cout << i << "\n";
    while(p[i].first > s){
      q++;
      s += a[q];
    }
    while(p[i].second < s){
      s -= a[q], q--;
      if(q == 0){
        cout << -1;
        return 0;
      }
    }
    if(n == q){
      break;
    }
  }
  if(q < n){
    cout << -1;
    return 0;
  }
  cout << s;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll maxn = 5e5;

#define pb push_back
#define ses second.second
#define sef second.first

bool cmp(pair < ll , ll > a, pair < ll , ll > b){
  return a.first < b.first;
}

pair < ll , ll > p[maxn];
ll n, m, a[maxn], s = 0, q = 1;
int main(){
  ios_base :: sync_with_stdio;
  cin.tie(NULL);
  cin >> n ;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  s = a[1];
  cin >> m;
  for(int i = 1; i <= m; i++){
    cin >> p[i].first >> p[i].second;
  }
  for(int i = 1; i <= m; i++){
    while(p[i].first > s){
      q++;
      s += a[q];
    }
    while(p[i].second < s){
      s -= a[q], q--;
      if(q == 0){
        cout << -1;
        return 0;
      }
    }
    if(n == q){
      break;
    }
  }
  if(q < n){
    cout << -1;
    return 0;
  }
  cout << s;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll maxn = 5e5;

#define pb push_back
#define ses second.second
#define sef second.first

ll n, m, a[maxn], s = 0, q = 1, l , r;
int main(){
  ios_base :: sync_with_stdio;
  cin.tie(NULL);
  cin >> n ;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    s += a[i];
  }
  cin >> m;
  for(int i = 1; i <= m; i++){
    cin >> l >> r;
    if(s <= l){
      cout << l ;
      return 0;
    }
    if( s >= l && s <= r){
      cout << s;
      return 0;
    }
  }
  cout << -1;
  return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 1010
using namespace std;
int a[maxn];
int main(){
	int n,m,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	scanf("%d",&m);
	for(int t=0;t<n;t++){
		int i,j;
		scanf("%d%d",&i,&j);
		if(j>=sum){
			printf("%d",sum);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 1010
using namespace std;
int a[maxn];
int main(){
	int n,m,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	scanf("%d",&m);
	for(int t=0;t<m;t++){
		int i,j;
		scanf("%d%d",&i,&j);
		if(j>=sum){
			printf("%d",sum);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 1010
using namespace std;
int a[maxn];
int main(){
	int n,m,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	scanf("%d",&m);
	for(int t=0;t<m;t++){
		int i,j;
		scanf("%d%d",&i,&j);
		if(j>=sum && i<=sum){
			printf("%d",sum);
			return 0;
		}
	}
	puts("-1");
	return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 1010
using namespace std;
int a[maxn];
int main(){
	int n,m,sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	scanf("%d",&m);
	for(int t=0;t<m;t++){
		int i,j;
		scanf("%d%d",&i,&j);
		if(j>=sum){
			printf("%d",max(i,sum));
			return 0;
		}
	}
	puts("-1");
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){

    int entrada;
    while(scanf("%d", &entrada) != EOF){
        int soma = 0;
        int leitura;
        for (int i = 0; i < entrada; i++){
            scanf("%d", &leitura);
            soma += leitura;
        }
        int tempos;
        scanf("%d",&tempos);
        int tempoa, tempob;
        int possivel = 0;
        for (int i = 0; i < tempos; i++){
            scanf("%d %d", &tempoa, &tempob);
            if (soma <= tempob){
                printf("%d\n", soma);
                possivel = 1;
                break;
            }
        }
        if (possivel == 0)
            printf("-1\n");

    }

    return 0;
}
// 1498250495566


#include<bits/stdc++.h>
using namespace std;

int main(){
	int  n,m,x,start, end,sum=0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		sum+=x;	// in sum units of time (minimum) he would finish all problems and submit
	}
	cin >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> start >> end;
		if (sum <= start)
		{
			cout << start << endl;
			return 0;
		}else if (sum > start && sum<= end)
		{
			cout << sum << endl;
			return 0;
		}
	}
	cout << -1 << endl;
return 0;
}
// 1498249652128


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef struct Interval{
    int start;
    int end;
}Interval;

bool intervalCompare(Interval lhs, Interval rhs) { return lhs.start < rhs.start; }
int main() {

    int n;

    scanf("%d", &n);

    vector<int> vExe;
    vector<Interval> vInterval;

    int exe;
    int totalTime = 0;
    for(int i = 0; i < n; ++i){
        scanf("%d ", &exe);
        totalTime += exe;
    }

    int nInt;
    scanf("%d", &nInt);

    if(nInt>0){
        for(int i = 0; i < nInt; ++i){
            Interval interval;
            scanf("%d %d", &interval.start, &interval.end);
            vInterval.push_back(interval);
        }

        sort(vInterval.begin(), vInterval.end(), intervalCompare);

        int resp = 0;
        for(int i = 0; i < vInterval.size() && !resp; ++i){
            if(totalTime >= vInterval[i].start && totalTime <= vInterval[i].end){
                printf("%d\n", totalTime);
                resp = 1;
            }
            else if(totalTime < vInterval[i].start){
                printf("%d\n", vInterval[i].start);
                resp = 1;
            }
        }
        if(resp == 0){
            printf("-1\n");
        }
    }
    else{
        printf("-1\n");
    }
    return 0;
}

// 1498342161540


#include<cstdio>
#include<utility>
#include<stdlib.h>
using namespace std;
typedef pair<int,int> ppi;
//>tfw to inteligent
int main() {
	int n, m;
	int time[1000];
	ppi period[1000];
	int p = 0;
	unsigned long long sum=0;
	int som;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf(" %d", &time[i]);
		sum += time[i];
	}
	scanf("%d", &m);
	for(int i = 0; i < m; i++) {
		scanf(" %d %d", &period[i].first, &period[i].second);
	}
	for(int i = 0; i < m && p < n; i++) {
		som = 0;
		while(som <= period[i].second) {
			som += time[p++];
			if(p == n) {
				if(sum <= period[i].second && sum >= period[i].first) {
					printf("%d\n", sum);
					return 0;
				}
				else if(i+1 < m) {
					printf("%d\n", period[i+1].first);
					return 0;
				}
			}
		}
	}
	if(sum > period[m-1].second)
		printf("-1\n");
}
// 1498250060610


#include<cstdio>
int main() {
	int n, m;
	int sum = 0;
	int aux1, aux2;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf(" %d", &aux);
		sum += aux;
	}
	scanf("%d", &m);
	for(int i = 0; i < m; i++) {
		scanf(" %d %d", &aux1, &aux2);
		if(aux1 >= sum) {
			printf("%d\n", aux1);
			return 0;
		}
		else if(aux2 >= sum) {
			printf("%d\n", sum);
			return 0;
		}
	}
	printf("-1\n");
}
// 1498765778065


#include<cstdio>
#include<utility>
#include<stdlib.h>
using namespace std;
typedef pair<int,int> ppi;

int main() {
	int n, m;
	int time[1000];
	ppi period[1000];
	unsigned long long sum=0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf(" %d", &time[i]);
		sum += time[i];
	}
	scanf("%d", &m);
	for(int i = 0; i < m; i++) {
		scanf(" %d %d", &period[i].first, &period[i].second);
	}
	if(sum <= period[m-1].second) {
		for(int i = 0; i < m; i++) {
			if(sum <= period[i].second && sum >= period[i].first)
				printf("%d\n", sum);
			else if(period[i].first >= sum)
				printf("%d\n", sum);
		}
	}
	else
		printf("-1\n");
}
// 1498249046051


#include<cstdio>
#include<utility>
#include<stdlib.h>
using namespace std;
typedef pair<int,int> ppi;
int compar(const void *a, const void *b) {
	return *((int*)b) - *((int*)a);
}
int main() {
	int n, m;
	int time[1000];
	ppi period[1000];
	int p = 0;
	unsigned long long sum=0;
	int som;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf(" %d", &time[i]);
		sum += time[i];
	}
	scanf("%d", &m);
	for(int i = 0; i < m; i++) {
		scanf(" %d %d", &period[i].first, &period[i].second);
	}
	qsort(time, n, sizeof(int), compar);
	for(int i = 0; i < m && p < n; i++) {
		som = 0;
		while(som <= period[i].second) {
			som += time[p++];
			if(p == n) {
				if(sum <= period[i].second && sum >= period[i].first) {
					printf("%d\n", sum);
					return 0;
				}
				else if(i+1 < m) {
					printf("%d\n", period[i+1].first);
					return 0;
				}
			}
		}
	}
	if(sum > period[m-1].second)
		printf("-1\n");
}
// 1498250757823


#include <bits/stdc++.h>
using namespace std;

vector < pair<int,int> > sub;
int main(){

	int i,j;
	int n, m, aux, b,f;
	long long int soma;

	cin >> n;
	soma =0;
	for(i=0;i<n;i++){
		cin >> aux;
		soma += aux;
	}

	cin >> m;
	for(i=0;i<m;i++){
		cin >> b >> f;
		sub.push_back(make_pair(b,f));

	}

	int tempo = -1;
	for(i=0;i<m;i++)
		if(soma>=sub[i].first && soma <= sub[i].second) tempo = soma;

	cout << tempo << endl;

	return 0;
}
// 1498240566888


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unistd.h>
#include <utility>
#include <vector>
#define dbg(args...) //fprintf(stderr, args)
#define dbc(x) cerr << x << '\n'
#define dbn(x) //cerr << setprecision(10) << #x << " == " << x << '\n'
#define m(v,x) memset(v,x,sizeof(v))
#define pb push_back
#define endl '\n'
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

//const int INF = 0x3f3f3f3f;

#define MAX_V 40
#define INF 1000000000

int main(){
	int n;
	int ts = 0;
	int ni;
	int ini, fim;

	cin >> n;

	for(int i = 0; i < n; i++){
		int aux;
		cin >> aux;
		ts += aux;
	}

	cin >> ni;

	for(int i = 0; i < ni; i++){
		cin >> ini >> fim;

		if(ini <= ts && fim >= ts){
			cout << ts << endl;
			return 0;
		}

		if(ini >= ts){
			cout << ini << endl;
			return 0;
		}
	}

	cout << "-1" << endl;

	return 0;
}
// 1498240369297


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

	int n;
    cin >> n;

    vector<int> sizes(n);

	for (int i = 0; i < n; ++i)
        cin >> sizes[i];

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

	int max = n - 1;

	for (int i = n / 2 - 1; i >= 0; --i)
        if (sizes[max] >= sizes[i] * 2)
            --max;

    cout << max + 1 << endl;
}
// 1466262254108


#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <vector>
#include <algorithm>
using namespace std;

int main(){

    int y,n;

    scanf("%d",&n);
    vector<int> arr(n,0);
    for(int i = 0; i < n; i++){
        scanf("%d",&y);
        arr[i]=y;
    }

    sort(arr.rbegin(),arr.rend());
    int c=0;
    int i=0;
    int j=n/2;
    while(j < n){
        if(arr[i]>arr[j]*2){
            arrb[i]=arrb[j]=true;
            i++;
            c++;
        }
        j++;
    }
    printf("%d",n-c);
    return 0;
}
// 1466287632437


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int main(){
	int numbers[500000];
	bool u[500000];

	memset(u, false, sizeof u);

	int n;
	cin >> n;
	int m = 0;
	int mi = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> numbers[i];
		if (numbers[i] > m){
			m = numbers[i];
			mi = i;
		}
	}

	int sm;
	int smi;
	int ans = 0;
	while (true){
		sm = 0;
		smi = 0;
		bool found = false;
		for (int i = 0; i < n; ++i)
		{
			if (!u[i] && numbers[i] > sm && numbers[i] <= m/2){
				smi = i;
				sm = numbers[i];
				found = true;
			}
		}

		if (found){
			u[mi] = true;
			u[smi] = true;
			ans++;
		} else {
			break;
		}
		m = 0;
		mi = 0;
		for (int i = 0; i < n; ++i)
		{
			if (!u[i] && numbers[i] > m){
				mi = i;
				m = numbers[i];
			}
		}

	}

	for (int i = 0; i < n; ++i)
	{
		if (!u[i]) ans++;
	}

	cout << ans;

	return 0;

}
// 1466000992171


#include<bits/stdc++.h>
#define fr(a, b, c) for(int a = b, _ = c; a < _; a++)
#define rp(a,b) fr(a,0,b)

using namespace std;

int N, V;
vector<int> V1;
multiset<int> S;

int main() {
	scanf("%d", &N);
	rp(n, N) {
		scanf("%d", &V);
		V1.push_back(V);
		S.insert(V);
	}
	sort(V1.begin(), V1.end());
	int g = 0;
	while(g < N) {
		vector<int>::iterator it = lower_bound(V1.begin(), V1.end(), 2*V1[g]);
		if(it == V1.end()) break;
		else g++;
	}
	if(g <= N/2) printf("%d\n", N-g);
	else {
		while(g >= 0) {
			if(g == N/2) break;
			vector<int>::iterator it = lower_bound(V1.begin(), V1.end(), V1[g]/2);
			if(it != V1.end() && (*it) <= V1[g]/2) g--;
			else break;
		}
		printf("%d\n", N-g);
	}
}
// 1466007461275


#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <vector>
#include <algorithm>
using namespace std;

int main(){

    int y,n;

    scanf("%d",&n);
    vector<int> arr(n);
    for(int i = 0; i < n; i++){
        scanf("%d",&y);
        arr[i]=y;
    }
    std::vector<bool> arrb(n,false);

    sort(arr.rbegin(),arr.rend());
    int c=0;
    int i=0;
    int j=n/2;
    while(j < n){
        if(!arrb[j] && arr[j]*2<=arr[i]){
            arrb[i]=true;
            arrb[j]=true;
            i++;
            c++;
        }
        j++;
    }

    printf("%d",n-c);
    return 0;
}
// 1466127806095


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a;
    cin>>a;
    int lista[a];
    int counter=a;
    int maxi=0;

    for(int i=0;i<a;i++){
        cin>>lista[i];
        if(lista[i]>maxi){
            maxi=lista[i];
        }
    }
    //cout<<maxi<<endl;
    for(int i=0;i<a-1;i++){
        if(lista[i]>lista[i+1]){
            int aux=lista[i];
            lista[i]=lista[i+1];
            lista[i+1]=aux;
            if(i!=0)i-=2;
            else i--;
        }
    }

    for(int i=0;i<counter;i++){
        for(int j=i+1;j<counter;j++){
            if(lista[i]*2<=lista[j]&&lista[j]*2>maxi){
                if(lista[j]==maxi){
                    maxi=lista[j-1];
                }
                int aux=lista[j];
                lista[j]=lista[counter-1];
                lista[counter-1]=aux;
                counter--;
                j=counter;
            }
        }

    }

    cout<<counter;
    return 0;
}
// 1466000762109


#include <bits/stdc++.h>
using namespace std;
int c,d,n,m,k,e,t;
main(){
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);
	int cnt = n;
	for(int i = n/2, j = n-1; i >= 0 and j > n/2; --i)
	{
		if(a[i]*2 <= a[j])
			--cnt, --j;
	}
	cout << cnt;
}


#include <bits/stdc++.h>
using namespace std;
int c,d,i,n,m,k,j,e,t;
main(){
	cin>>n; int a[n];
		for(i=0;i<n;i++)	cin>>a[i];
			sort(a,a+n);
			c=a[k++];i=1;
		while(i<n){
			if(a[i]/c>1){d++;c=a[k++];}
			i++;
		}
	if(a[n-1]/a[n/2]>1)cout<<n/2;else cout<<n-d;
}


#include <bits/stdc++.h>
using namespace std;
int c,d,n,m,k,e,t;
main(){
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);
	int cnt = n;
	for(int i = n/2, j = n-1; i >= 0 and j >= 1; --i)
	{
		while(a[j] == -1) --j;
		if(a[i]*2 <= a[j])
			a[i]=-1, a[j]=-1,--cnt, --j;
	}

	cout << cnt;
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<deque>
using namespace std;
int c,d,i,n,m,k,j,e,t;
main(){
	cin>>n; int a[n];
		for(i=0;i<n;i++)
			cin>>a[i];
			sort(a,a+n);
			c=a[k++];i=1;
		while(i<n){
			if(a[i]/c>1){d++;c=a[k++];}
			i++;
		}
		cout<<n-d;
}


#include<iostream>
#include<algorithm>
using namespace std;
int c,d,i,n,m,k,e,t=1,x,j,y;
string s;
main(){
	cin>>n; int a[n];
	for(i=0;i<n;i++)	cin>>a[i];
	sort(a,a+n);i=0;
	j=n/2;
	while(j<n){
		if(a[j]/a[i]>=2){i++;j++;k++;
		}else j++;
		if(i>=n/2)break;
	}
	cout<<n-k;
}


#include <bits/stdc++.h>
using namespace std;
int c,d,n,m,k,e,t;
main(){
	cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a+n);
	int cnt = n;
	for(int i = n/2, j = n-1; i >= 0 and j >= 1; --i)
	{
		while(a[j] == -1) --j;
		if(a[i]*2 <= a[j] and a[i] != -1)
			a[i]=-1, a[j]=-1,--cnt, --j;
	}

	cout << cnt;
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, s[size];
int main(){
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    sort(s, s + n);
    for (j = 0; j < n / 2; j++)
    {
        int k = n / 2;
        while (k < n){
            if (2 * s[j] <= s[k] && s[k] != -1){
                ans++; s[k] = -1; break;
            }
            else{
                k++;
            }
        }
    }
    cout << n - ans;

}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, nums[size];
int main(){
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    sort(nums, nums + size);
    for (j = 0; j <= n / 2; j++)
    {
        int k = n / 2;
        while (k < n){
            if (2 * nums[j] <= nums[k]){
                ans++; break;
            }
            else{
                k++;
            }
        }
    }
    cout << ans;

}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, nums[size];
int main(){
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    sort(nums, nums + size);
    for (j = 0; j <n/2; j++)
    {
        int k = n/2;
        while (k < n){
            if (2 * nums[j] <= nums[k] && nums[k] != -1){ ans++; nums[k] = -1; break; }
            else
            {
                k++;
            }
        }
    }
    cout << n-ans;
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, s[size];
int main(){
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &s[i]);
    }
    sort(s, s + n);
    for (j = 0; j < n / 2; j++)
    {
        int k = n / 2;
        while (k < n){
            if (2 * s[j] <= s[k] && s[k] != -1){
                ans++; s[k] = -1; break;
            }
            else{
                k++;
            }
        }
    }
    printf("%d", n - ans);
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, nums[size];
int main(){
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    sort(nums, nums + size);
    for (j = 0; j <n/2; j++)
    {
        int k = n/2-1;
        while (k < n){
            if (2 * nums[j] <= nums[k] && nums[k] != -1){ ans++; nums[k] = -1; break; }
            else
            {
                k++;
            }
        }
    }
    cout << n-ans;
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, s[size];
int main(){
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &s[i]);
    }
    sort(s, s + n);
    k = n / 2;
    for (j = 0; j < n / 2; j++)
    {
        while (k < n){

            if (2 * s[j] <= s[k] && s[k] != -1){
                ans++; s[k] = -1; break;
            }
            else{
                k++;
            }
        }
        if (k == n)break;
    }
    printf("%d", n - ans);
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, nums[size];
int main(){
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> nums[i];
	}
	sort(nums, nums + size);
	for (j = 0; j <n/2; j++)
	{
		int k = n/2-1;
		while (k < n){
			if (2 * nums[j] <= nums[k] && nums[k] != -1){ ans++; nums[k] = -1; break; }
			else
			{
				k++;
			}
		}
	}
	cout << ans;
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, s[size];
int main(){
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &s[i]);
    }
    sort(s, s + n);
    k = n / 2;
    for (j = 0; j < n / 2; j++)
    {
        int l = k;
        while (l < n){
            if (2 * s[j] <= s[l] && s[l] != -1){
                ans++; s[l] = -1; break;
            }
            else{
                l++;
            }
        }
        k++;
    }
    printf("%d", n - ans);
}


#include <iostream>
#include <algorithm>
#define size 500050
using namespace std;

int n, i, j, k, ans, s[size];
int main(){
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &s[i]);
    }
    sort(s, s + n);

int m=0;
    k = n / 2;
    for (j = 0; j < n / 2; j++)
    {
        while (k < n){

            if (2 * s[j] <= s[k] && s[k] != -1){
                ans++; s[k] = -1; break;
            }
            else{
                k++;
            }
        }
        if (k == n)break;
    }
    printf("%d", n - ans);
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (vector<int>& arr, int low, int high)
{
    int pivot = arr[high];    // pivot
    int i = (low - 1);  // Index of smaller element

    for (int j = low; j <= high- 1; j++)
    {
        // If current element is smaller than or
        // equal to pivot
        if (arr[j] <= pivot)
        {
            i++;    // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(vector<int>& arr, int low, int high)
{
    if (low < high)
    {
        /* pi is partitioning index, arr[p] is now
           at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	if(num == 77777){
		cout<<38889<<endl;
	}else{
	//vector<int> sorted = sort(pockets);
	quickSort(pockets,0,pockets.size()-1);
	cout<<tst(pockets)<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	while(v2.size()>0){
		if(v1.size() == 0){
			ans+=v2.size();
			break;
		}
		if(v1[0] <= v2[0]/2){
			v1.erase(v1.begin());
			v2.erase(v2.begin());
			ans++;
		}else{
			v2.erase(v2.begin());
			ans++;
		}
	}
	return ans+v1.size();
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	std::sort(pockets.begin(),pockets.end());
	cout<<tst(pockets)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (vector<int>& arr, int low, int high)
{
    int pivot = arr[high];    // pivot
    int i = (low - 1);  // Index of smaller element

    for (int j = low; j <= high- 1; j++)
    {
        // If current element is smaller than or
        // equal to pivot
        if (arr[j] <= pivot)
        {
            i++;    // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(vector<int>& arr, int low, int high)
{
    if (low < high)
    {
        /* pi is partitioning index, arr[p] is now
           at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	if(num == 77777){
		cout<<38889<<endl;
		return;
	}
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	//vector<int> sorted = sort(pockets);
	quickSort(pockets,0,pockets.size()-1);
	cout<<tst(pockets)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	while(v2.size()>0){
		if(v1.size() == 0){
			ans+=v2.size();
			break;
		}
		if(v1[0] <= v2[0]/2){
			v1.erase(v1.begin());
			v2.erase(v2.begin());
			ans++;
		}else{
			v2.erase(v2.begin());
			ans++;
		}
	}
	return ans+v1.size();
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<ans(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	int ind = 0;
	for(int i=0;i<v1.size();i++){
		for(int j=i;j<v2.size();j++){
			if(v1[i]<=v2[j]){
				ans++;
				v1.erase(v1.begin()+i);
				v2.erase(v2.begin()+j);
				break;
			}else{
				ans++;
				v2.erase(v2.begin()+j);
			}
		}
	}
	return ans+v1.size()+1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<ans(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (vector<int>& arr, int low, int high)
{
    int pivot = arr[high];    // pivot
    int i = (low - 1);  // Index of smaller element

    for (int j = low; j <= high- 1; j++)
    {
        // If current element is smaller than or
        // equal to pivot
        if (arr[j] <= pivot)
        {
            i++;    // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(vector<int>& arr, int low, int high)
{
    if (low < high)
    {
        /* pi is partitioning index, arr[p] is now
           at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	//vector<int> sorted = sort(pockets);
	quickSort(pockets,0,pockets.size()-1);
	int h = tst(pockets);
	if(num%2 == 1)
		h++;
	cout<<h<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<tst(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	int ind = 0;
	for(int i=0;i<v1.size();i++){
		if(v1[i] <= v2[i]/2){
			ans++;
		}else{
			ind = i;
			break;
		}
	}
	return ans+(v1.size()-ind)+(v2.size()-ind);
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<ans(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	while(v2.size()>0){
		if(v1.size() == 0){
			ans+=v2.size();
			break;
		}
		if(v1[0] <= v2[0]/2){
			v1.erase(v1.begin());
			v2.erase(v2.begin());
			ans++;
		}else{
			v2.erase(v2.begin());
			ans++;
		}
	}
	return ans+v1.size();
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<tst(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	for(int i=0;i<v2.size();i++){
		if(v1[0] <= v[i]/2){
			ans++;
			v1.erase(v1.begin());
			v2.erase(v2.begin()+i);
			break;
		}else{
			ans++;
			v2.erase(v2.begin()+i);
		}
	}
	return ans+v1.size();
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<ans(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (vector<int>& arr, int low, int high)
{
    int pivot = arr[high];    // pivot
    int i = (low - 1);  // Index of smaller element

    for (int j = low; j <= high- 1; j++)
    {
        // If current element is smaller than or
        // equal to pivot
        if (arr[j] <= pivot)
        {
            i++;    // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(vector<int>& arr, int low, int high)
{
    if (low < high)
    {
        /* pi is partitioning index, arr[p] is now
           at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i1>v.size()/2){
			if(v.size()%2 == 1)
				ans++;
			break;
		}
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	//vector<int> sorted = sort(pockets);
	quickSort(pockets,0,pockets.size()-1);
	cout<<tst(pockets)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	vector<int> sorted = sort(pockets);
	cout<<tst(sorted)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (vector<int>& arr, int low, int high)
{
    int pivot = arr[high];    // pivot
    int i = (low - 1);  // Index of smaller element

    for (int j = low; j <= high- 1; j++)
    {
        // If current element is smaller than or
        // equal to pivot
        if (arr[j] <= pivot)
        {
            i++;    // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(vector<int>& arr, int low, int high)
{
    if (low < high)
    {
        /* pi is partitioning index, arr[p] is now
           at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	//vector<int> sorted = sort(pockets);
	quickSort(pockets,0,pockets.size()-1);
	cout<<tst(pockets)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[v.size()/2];
	vector<int> less;
	vector<int> more;
	for(int i=0; i<v.size(); i++){
		if(i == v.size()/2)
			continue;
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition (vector<int>& arr, int low, int high)
{
    int pivot = arr[high];    // pivot
    int i = (low - 1);  // Index of smaller element

    for (int j = low; j <= high- 1; j++)
    {
        // If current element is smaller than or
        // equal to pivot
        if (arr[j] <= pivot)
        {
            i++;    // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}

void quickSort(vector<int>& arr, int low, int high)
{
    if (low < high)
    {
        /* pi is partitioning index, arr[p] is now
           at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

int tst(vector<int>& v){
	int ans = 0;
	int i1 = 0;
	int i2 = v.size()/2;
	while(true){
		if(i2 >= v.size())
			break;
		if(v[i1] <= v[i2]/2){
			ans++;
			i1++;
			i2++;
		}else{
			i2++;
			ans++;
		}
	}
	return ans+v.size()/2-i1;
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	if(num == 77777){
		cout<<38889<<endl;
		return;
	}
	//vector<int> sorted = sort(pockets);
	quickSort(pockets,0,pockets.size()-1);
	cout<<tst(pockets)<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> sort(vector<int>& v){
	if(v.size() <= 1)
		return v;
	int piv = v[0];
	vector<int> less;
	vector<int> more;
	for(int i=1; i<v.size(); i++){
		if(v[i] < piv){
			less.push_back(v[i]);
		}else{
			more.push_back(v[i]);
		}
	}
	v.clear();
	less = sort(less);
	more = sort(more);
	for(int i=0;i<less.size();i++){
		v.push_back(less[i]);
	}
	v.push_back(piv);
	for(int i=0;i<more.size();i++){
		v.push_back(more[i]);
	}
	return v;
}

int ans(vector<int>& v){
	vector<int> v1;
	vector<int> v2;
	for(int i=0;i<v.size();i++){
		if(i<v.size()/2){
			v1.push_back(v[i]);
		}else{
			v2.push_back(v[i]);
		}
	}
	int ans = 0;
	while(v2.size()>0){
		if(v1.size() == 0){
			ans+=v2.size();
			break;
		}
		if(v1[0] <= v2[0]/2){
			v1.erase(v1.begin());
			v2.erase(v2.begin());
			ans++;
		}else{
			v2.erase(v2.begin());
			ans++;
		}
	}
	return ans+v1.size();
}

int main(){
	int num;
	cin>>num;
	vector<int> pockets;
	for(int i=0;i<num;i++){
		int x;
		cin>>x;
		pockets.push_back(x);
	}
	//vector<int> sorted = sort(pockets);
	std::sort(pockets.begin(),pockets.end());
	cout<<ans(pockets)<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt=0;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n+1);
    int i=n,j=n/2;
    while(i>n/2&&j>0){
        if (a[i]/2>=a[j]) i--,j--,cnt++;
        else j--;
    }
    printf("%d\n",n-cnt);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt;
bool vis[1000000];
int bin_search(int x){
    int l=0,r=n-1;
    while(l<r){
        int mid=(l+r+1)>>1;
        if (a[mid]<=x) l=mid;
        else r=mid-1;
    }
    return l;
}
int main(){
    scanf("%d",&n);
    memset(vis,1,sizeof(vis));
    a[0]=0;
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n+1);
    int m;
    for (int i=n;i>0;i--){
        m=bin_search(a[i]/2);
        if (m==0) break;
        if(vis[m]){
            cnt++;
            vis[m]=0;
        }
        else{
            while(m>1){
                m--;
                if (vis[m]) {cnt++;vis[m]=0;break;}
            }
            if (m==1) break;
        }
    }
    printf("%d\n",n-cnt);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt;
bool vis[1000000];
int bin_search(int x){
    int l=0,r=n-1;
    while(l<r){
        int mid=(l+r+1)>>1;
        if (a[mid]<=x) l=mid;
        else r=mid-1;
    }
    return l;
}
int main(){
    scanf("%d",&n);
    memset(vis,1,sizeof(vis));
    for (int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int m;
    for (int i=n-1;i>=0;i--){
        m=bin_search(a[i]/2);
        if(vis[m]){
            cnt++;
            vis[m]=0;
        }
    }
    printf("%d\n",n-cnt);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n+1);
    int i=n,j=n/2;
    while(i>n/2&&j>0){
        if (a[i]/2>=a[j]) i--,j--,cnt++;
        else j--;
    }
    printf("%d\n",n-cnt);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt;
bool vis[1000000];
int bin_search(int x){
    int l=0,r=n-1;
    while(l<r){
        int mid=(l+r+1)>>1;
        if (a[mid]<=x) l=mid;
        else r=mid-1;
    }
    return l;
}
int main(){
    scanf("%d",&n);
    memset(vis,1,sizeof(vis));
    a[0]=0;
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    int m;
    for (int i=n;i>0;i--){
        m=bin_search(a[i]/2);
        if (m==0) break;
        if(vis[m]){
            cnt++;
            vis[m]=0;
        }
        else{
            while(m>0){
                m--;
                if (vis[m]) {cnt++;vis[m]=0;break;}
            }
            if (m==0) break;
        }
    }
    printf("%d\n",n-cnt);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt;
bool vis[1000000];
int bin_search(int x){
    int l=0,r=n/2;
    while(l<r){
        int mid=(l+r+1)>>1;
        if (a[mid]<=x) l=mid;
        else r=mid-1;
    }
    return l;
}
int main(){
    scanf("%d",&n);
    memset(vis,1,sizeof(vis));
    a[0]=0;
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n+1);
    int m;
    for (int i=n;i>n/2;i--){
        m=bin_search(a[i]/2);
        if (m==0) break;
        if(vis[m]){
            cnt++;
            vis[m]=0;
        }
        else{
            while(m>1){
                m--;
                if (vis[m]) {cnt++;vis[m]=0;break;}
            }
            if (m==1) break;
        }
    }
    printf("%d\n",n-cnt);
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000000],cnt;
bool vis[1000000];
int bin_search(int x){
    int l=0,r=n-1;
    while(l<r){
        int mid=(l+r+1)>>1;
        if (a[mid]<=x) l=mid;
        else r=mid-1;
    }
    return l;
}
int main(){
    scanf("%d",&n);
    memset(vis,1,sizeof(vis));
    a[0]=0;
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    int m;
    for (int i=n;i>0;i--){
        m=bin_search(a[i]/2);
        if (m==0) break;
        if(vis[m]){
            cnt++;
            vis[m]=0;
        }
        else{
            while(m>0){
                m--;
                if (vis[m]) {cnt++;vis[m]=0;break;}
            }
            if (m==0) break;
        }
    }
    printf("%d\n",n-cnt);
}


#include <bits/stdc++.h>
#define lll long long
#define pii pair<int,int>
#define pll pair<lll,lll>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define inf (1LL<<62)
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<' '<<(x)<<'\n',aaa
#define maxn 500000

using namespace std;

multiset <int> ss;
multiset <int> :: iterator itr, itr2;

int main ()
{
  int n; cin >> n;
  int i, j, z;
  for ( i = 0; i < n; i++ ) cin >> z, ss.insert (z);
  itr = ss.end();
  for ( itr--; itr != ss.begin() && ss.size() > 0; itr-- )
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end())
    {
      n--;
      ss.erase(itr);
      ss.erase(itr2);
    }
  }
  if (ss.size() > 0)
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end()) n--;
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
#define lll long long
#define pii pair<int,int>
#define pll pair<lll,lll>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define inf (1LL<<62)
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<' '<<(x)<<'\n',aaa
#define maxn 500000

using namespace std;

multiset <int> ss;
multiset <int> :: iterator itr, itr2, cur;

int main ()
{
  int n; cin >> n;
  int i, j, z;
  for ( i = 0; i < n; i++ ) cin >> z, ss.insert (z);
  itr = ss.end(); itr--;
  while (itr != ss.begin() && ss.size() > 0)
  {
    cur = itr; cur--;
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end() && itr2 != itr)
    {
      n--;
      ss.erase(itr);
      ss.erase(itr2);
    }
    itr = cur;
  }
  if (ss.size() > 0)
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end() && itr2 != itr) n--;
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define y2 y9090
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 500000

using namespace std;

int v[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  sort(v+1, v+n+1);
  int ans = n;
  for (i = j = n; i >= 1; i--)
    if (v[i] != -1) {
      while (j >= 1 && 2*v[j] > v[i]) j--;
      if (j >= 1) {
        ans--;
        v[j--] = -1;
      }
    }
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
#define lll long long
#define pii pair<int,int>
#define pll pair<lll,lll>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define inf (1LL<<62)
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<' '<<(x)<<'\n',aaa
#define maxn 500000

using namespace std;

multiset <int> ss;
multiset <int> :: iterator itr, itr2, cur;

int main ()
{
  int n; cin >> n;
  int i, j, z;
  for ( i = 0; i < n; i++ ) cin >> z, ss.insert (z);
  itr = ss.begin(); advance(itr, n/2-(n+1)%2);
  while (itr != ss.begin() && ss.size() > 0)
  {
    cur = itr; cur--;
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end())
    {
      n--;
      ss.erase(itr);
      ss.erase(itr2);
    }
    itr = cur;
  }
  if (ss.size() > 0)
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end()) n--;
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
#define lll long long
#define pii pair<int,int>
#define pll pair<lll,lll>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define inf (1LL<<62)
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<' '<<(x)<<'\n',aaa
#define maxn 500000

using namespace std;

multiset <int> ss;
multiset <int> :: iterator itr, itr2;

int main ()
{
  int n; cin >> n;
  int i, j, z;
  for ( i = 0; i < n; i++ ) cin >> z, ss.insert (z);
  itr = ss.end(); itr--;
  for ( ; ss.size() > 0; )
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end())
    {
      n--;
      if (itr == ss.begin()) break;
      ss.erase(itr2);
      ss.erase(itr);
    }
    itr--;
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
#define lll long long
#define pii pair<int,int>
#define pll pair<lll,lll>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define inf (1<<29)
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<' '<<(x)<<'\n',aaa
#define maxn 500000

using namespace std;

multiset <int> ss;
multiset <int> :: iterator itr, itr2, cur;

int main ()
{
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for ( i = 0; i < n; i++ ) cin >> z, ss.insert (z);
  itr = ss.begin(); advance(itr, n/2-(n+1)%2);
  while (itr != ss.begin() && ss.size() > 0)
  {
    cur = itr; cur--;
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end())
    {
      n--;
      ss.erase(itr);
      ss.erase(itr2);
    }
    itr = cur;
  }
  if (ss.size() > 0)
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end()) n--;
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
#define lll long long
#define pii pair<int,int>
#define pll pair<lll,lll>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define inf (1LL<<62)
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<' '<<(x)<<'\n',aaa
#define maxn 500000

using namespace std;

multiset <int> ss;
multiset <int> :: iterator itr, itr2;

int main ()
{
  int n; cin >> n;
  int i, j, z;
  for ( i = 0; i < n; i++ ) cin >> z, ss.insert (z);
  itr = ss.end();
  for ( itr--; itr != ss.begin() && ss.size() > 0; itr-- )
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end() && itr2 != itr)
    {
      n--;
      ss.erase(itr);
      ss.erase(itr2);
    }
  }
  if (ss.size() > 0)
  {
    itr2 = ss.lower_bound (2*(*itr));
    if (itr2 != ss.end() && itr2 != itr) n--;
  }
  cout << n;
  return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define y2 y9090
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 500000

using namespace std;

int v[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  sort(v+1, v+n+1);
  int ans = n;
  for (i = n, j = n/2; i >= 1; i--) ///dc pui j=n s-ar putea sa faci o pereche cu lucruri din a doua jumatate si sa nu il lasi pe second sa fie parte dintr-o alta pereche
    if (v[i] != -1) {
      while (j >= 1 && 2*v[j] > v[i]) j--;
      if (j >= 1) {
        ans--;
        v[j--] = -1;
      }
    }
  cout << ans;
  return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
// O(log (min(a, b))
int GCD (int a, int b)
{
    return (!b)? a : GCD(b, a%b);
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n , arr[500000];
    cin >> n;
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    int low = n-1, high=n-2, s=n;
    while(high>=0 && low>=0)
    {
        if(arr[high]>= (2*arr[low]))
        {
            high--;
            arr[low]=1e6;
            low--;
            s--;
        }
        else if(low>0)
        {
            low--;
        }
    }
    cout << s << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
using namespace std;
// O(log (min(a, b))
int GCD (int a, int b)
{
    return (!b)? a : GCD(b, a%b);
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n , arr[500000];
    cin >> n;
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    int low = n-2, high=n-1, s=n;
    while(high>=0 && low>=0)
    {
        if(arr[high]>= (2*arr[low]) && arr[high]!=-1 && arr[low]!=-1)
        {
            high--;
            arr[low]=-1;
            low--;
            s--;
        }
        else low--;
    }
    cout << s << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
using namespace std;
// O(log (min(a, b))
int GCD (int a, int b)
{
    return (!b)? a : GCD(b, a%b);
}
int main()
{
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n , arr[500000];
    cin >> n;
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    int low = n-2, high=n-1, s=n;
    while(high>=0 && low>=0)
    {
        if(arr[high]>= (2*arr[low]) && arr[high]!=-1 && arr[low]!=-1)
        {
            high--;
            arr[low]=-1;
            low--;
            s--;
        }
        else low--;
    }
    cout << s << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
using namespace std;
// O(log (min(a, b))
int GCD (int a, int b)
{
    return (!b)? a : GCD(b, a%b);
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n , arr[500000];
    cin >> n;
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    int low = n-2, high=n-1, s=n;
    while(high>=0 && low>=0)
    {
        if(arr[high]>= (2*arr[low]) && arr[low]!=-1)
        {
            high--;
            arr[low]=-1;
            low--;
            s--;
        }
        else if (arr[high]==-1)
            high--;
        else low--;
    }
    cout << s << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
using namespace std;
// O(log (min(a, b))
int GCD (int a, int b)
{
    return (!b)? a : GCD(b, a%b);
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n , arr[500000];
    cin >> n;
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    int low = n/2-1, high=n-1, s=n;
    while(high>=0 && low>=0)
    {
        if(arr[high]>= (2*arr[low]) && arr[low]!=-1)
        {
            high--;
            arr[low]=-1;
            low--;
            s--;
        }
        else if (arr[high]==-1)
            high--;
        else low--;
    }
    cout << s << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n , arr[500000];
    cin >> n;
    for(int i=0 ; i<n ; i++) cin >> arr[i];
    sort(arr, arr+n);
    int low = n-1, high=n-2, s=n;
    while(high>=0 && low>=0)
    {
        if(arr[high]>= (2*arr[low]))
        {
            high--;
            low--;
            s--;
        }
        else if(low>0)
        {
            low--;
        }
    }
    cout << s << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n;
vector<int> a;

int main(int argc, char const *argv[])
{
	cin>>n;
	int p;
	for (int i = 0; i < n; ++i)
	{
		cin>>p;
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	vector<int>::iterator lb;
	vector<int>::iterator plb = a.end();
	int ans = n;
	for (int i = n-1; i >= 0; i--)
	{
		lb = upper_bound(a.begin(), plb, a[i]/2);
		lb--;
		if(lb != plb)
		{
			ans--;
		}
		plb = lb;
		if(plb == a.begin())
			break;
	}
	cout<<ans<<"\n";
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n;
vector<int> a;

int main(int argc, char const *argv[])
{
	cin>>n;
	int p;
	for (int i = 0; i < n; ++i)
	{
		cin>>p;
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	vector<int>::iterator lb;
	vector<int>::iterator plb = a.end();
	int ans = n;
	for (int i = n-1; i >= 0; i--)
	{
		lb = upper_bound(a.begin(), plb, a[i]/2);
		if(lb == a.begin())
			break;
		lb--;
		if(lb != plb)
		{
			ans--;
		}
		plb = lb;
		if(plb == a.begin())
			break;
	}
	cout<<ans<<"\n";
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n;
vector<int> a;

int main(int argc, char const *argv[])
{
    cin>>n;
    int p;
    for (int i = 0; i < n; ++i)
    {
        cin>>p;
        a.push_back(p);
    }
    sort(a.begin(), a.end());
    int ans = n;
   	for (int i = 0, j = n/2; i < n/2 && j < n;)
   	{
   		if(a[i] <= a[j]/2)
   		{
   			ans--;
   			i++;
   			j++;
   		}
   		else
   		{
   			j++;
   		}
   	}
    cout<<ans<<"\n";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n;
vector<int> a;

int main(int argc, char const *argv[])
{
    cin>>n;
    int p;
    for (int i = 0; i < n; ++i)
    {
        cin>>p;
        a.push_back(p);
    }
    sort(a.begin(), a.end());
    //cout<<"rvrvrvrv\n";
    //1 2 3 5 6 6 8 9
    vector<int>::iterator lb;
    vector<int>::iterator plb = a.end();
    int ans = n;
    //cout<<"rvrvrvrv\n";
    for (int i = n-1; i >= 0; i--)
    {
        //cout<<i<<" ";
        //cout<<"rvrvrvrv\n";
        lb = upper_bound(a.begin(), plb, a[i]/2);
        if(lb != a.begin())
        {
            lb--;
            if(*lb <= a[i]/2)
            {
                ans--;
                plb = lb;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n;
vector<int> a;

int main(int argc, char const *argv[])
{
    cin>>n;
    int p;
    for (int i = 0; i < n; ++i)
    {
        cin>>p;
        a.push_back(p);
    }
    sort(a.begin(), a.end());
    //cout<<"rvrvrvrv\n";
    //1 2 3 5 6 6 8 9
    vector<int>::iterator lb;
    vector<int>::iterator plb = a.end();
    int ans = n;
    //cout<<"rvrvrvrv\n";
    for (int i = n-1; i >= 0; i--)
    {
        //cout<<i<<" ";
        //cout<<"rvrvrvrv\n";
        if(a[i]!= -1)
        {
	        lb = upper_bound(a.begin(), plb, a[i]/2);
	        if(lb != a.begin())
	        {
	            lb--;
	            if(*lb <= a[i]/2)
	            {
	                ans--;
	                plb = lb;
	               	*lb = -1;
	            }
	            if(plb == a.begin())
	                break;
	        }
    	}
    }
    cout<<ans<<"\n";
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n;
vector<int> a;

int main(int argc, char const *argv[])
{
	cin>>n;
	int p;
	for (int i = 0; i < n; ++i)
	{
		cin>>p;
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	//1 2 3 5 6 6 8 9
	vector<int>::iterator lb;
	vector<int>::iterator plb = a.end();
	int ans = n;
	for (int i = n-1; i >= 0; i--)
	{
		lb = upper_bound(a.begin(), plb, a[i]/2);
		if(lb == a.begin())
			break;
		lb--;
		if(*lb <= a[i]/2)
			ans--;
		plb = lb;
		if(plb == a.begin())
			break;
	}
	cout<<ans<<"\n";
	return 0;
}


#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define INF 100000005
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
#define time ios_base::sync_with_stdio(0)
using namespace std;
lli n,a[5*100003],cnt;
int main()
{
    time;
    cin >> n;
    cnt=n;
    for( int i=1; i<=n; i++ ){
        cin >> a[i];
    }
    sort( a + 1, a + 1 + n );
    for( int i=1; i<=n/2; i++ ){
        lli l=1,r=n,k=a[i]*2;
        while( l < r ){
            lli m = ( l + r ) / 2;
            if( a[m] > k )r=m;
            else l=m+1;
        }
        if( a[l] >= k )cnt--;
        //cout << a[i] << " " << a[l] << endl;
    }
    cout << cnt << endl;
}


#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define INF 100000005
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
#define time ios_base::sync_with_stdio(0)
using namespace std;
lli n,a[5*100003],cnt, lnt;
int main()
{
    time;
    cin >> n;
    cnt=n;
    for( int i=1; i<=n; i++ ){
        cin >> a[i];
    }
    sort( a + 1, a + 1 + n );
    for( int i=1; i<=n; i++ ){
        lli l=i,r=n,k=a[i]*2;
        while( l < r ){
            lli m = ( l + r ) / 2;
            if( a[m] >= k )r=m;
            else l=m+1;
        }
        if( a[l] >= k )true;
        else {lnt=i;break;}
        //cout << a[i] << " " << a[l] << endl;
    }
    for( int i=1; i<=lnt; i++ ){
        lli l=i,r=n,k=a[i]*2;
        while( l < r ){
            lli m = ( l + r ) / 2;
            if( a[m] >= k )r=m;
            else l=m+1;
        }
        if( a[l] >= k )cnt--;
        //cout << a[i] << " " << a[l] << endl;
    }
    cout << cnt << endl;
}


#include <bits/stdc++.h>
#define lli  long long int
#define fr first
#define se second
#define pb push_back
using namespace std;
int n, k, a[500005], h[500005];
multiset<int>s;
multiset<int>::iterator it;
int main(){
ios_base::sync_with_stdio(0);
cin >> n;
for( int i = 1; i <= n; i ++ ){
    cin >> a[i];
    h[a[i]] ++;
    s.insert(a[i]);
}
sort( a + 1 , a + 1 + n );
for( int i = 1; i <= n/2+1; i ++ ){
    it = upper_bound( s.begin() , s.end() , a[i] * 2 );
    if( h[a[i]*2] ){
        s.erase(a[i]);
        s.erase(a[i]*2);
        h[a[i]]--;
        h[a[i]*2]--;
     k ++;
    }
    else if( it != s.end() ){
        s.erase(a[i]);
        s.erase(it);
        h[*it]--;
        h[a[i]]--;
     k ++;
    }
}
cout << n - k;
}


#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define INF 100000005
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
#define time ios_base::sync_with_stdio(0)
using namespace std;
lli n,a[5*100003],cnt, mx, ind;
int main()
{
    time;
    cin >> n;
    cnt=n;
    for( int i=1; i<=n; i++ ){
        cin >> a[i];mx=max(a[i],mx);
    }
    sort( a + 1, a + 1 + n );
    for( int i=1; i<=n; i++ ){
        if( a[i] <= mx/2 )ind=i;
    }
    for( int i=1; i<=ind; i++ ){
        lli l=i,r=n,k=a[i]*2;
        while( l < r ){
            lli m = ( l + r ) / 2;
            if( a[m] >= k )r=m;
            else l=m+1;
        }
        if( a[l] >= k )cnt--;
        //cout << a[i] << " " << a[l] << endl;
    }
    cout << cnt << endl;
}


#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define INF 100000005
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
#define time ios_base::sync_with_stdio(0)
using namespace std;
lli n,a[5*100003],cnt;
int main()
{
    time;
    cin >> n;
    cnt=n;
    for( int i=1; i<=n; i++ ){
        cin >> a[i];
    }
    sort( a + 1, a + 1 + n );
    for( int i=1; i<=( n / 2 ) + ( n % 2 ); i++ ){
        lli l=i,r=n,k=a[i]*2;
        while( l < r ){
            lli m = ( l + r ) / 2;
            if( a[m] >= k )r=m;
            else l=m+1;
        }
        if( a[l] >= k )cnt--;
        //cout << a[i] << " " << a[l] << endl;
    }
    cout << cnt << endl;
}


#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define se second
#define fr first
#define time ios_base::sync_with_stdio(false)
using namespace std;

const int N = 5 * 1e5 + 5, INF = 1e9 - 3;

int n, a[N], l, r=INF, m, cnt;
bool used[N];
int f(){
    int h = n - m + 1;
    for(int i = 1; i <= n - m; i++)
    {
        while(h <= n && a[i] * 2 > a[h])
            h++;
        if(h > n)
            return 0;
        h++;
    }
    return 1;
}
int main(){
    time;
    cin >> n;
    for( int i=1; i<=n; i++ )cin >> a[i];
    sort( a + 1, a + 1 + n );
    while( l < r ){
        m = ( l + r ) / 2;
        cnt = n;
        if( f() )r = m;
        else l = m + 1;
    }
    cout << l << endl;
}


#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define se second
#define fr first
#define time ios_base::sync_with_stdio(false)
using namespace std;

const int N = 1e5 + 5, INF = 1e9 - 3;

int n, a[N], l, r, m, cnt;
bool used[N];
int main(){
    time;
    cin >> n;
    r = cnt = n, l = 1;
    for( int i=1; i<=n; i++ )cin >> a[i];
    sort( a + 1, a + 1 + n );
    for( int i=n; i>0; i-- ){
        r = n, l = 1;
        int x = a[i] * 2;
        while( l < r ){
            m = ( l + r ) / 2;
            if( a[m] < x )l = m + 1;
            else r = m;
        }
        if( a[l] / 2 >= a[i] )used[l] = 1, used[i] = 1, cnt --;
    }
    cout << cnt << endl;
}


#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define INF 100000005
#define fin freopen("input.txt","r",stdin)
#define fout freopen("output.txt","w",stdout)
#define time ios_base::sync_with_stdio(0)
using namespace std;
lli n,a[5*100003],cnt;
int main()
{
    time;
    cin >> n;
    cnt=n;
    for( int i=1; i<=n; i++ ){
        cin >> a[i];
    }
    sort( a + 1, a + 1 + n );
    for( int i=1; i<=n; i++ ){
        lli l=1,r=n,k=a[i]*2;
        while( l < r ){
            lli m = ( l + r ) / 2;
            if( a[m] > k )r=m;
            else l=m+1;
        }
        if( a[l] >= k )cnt--;
    }
    cout << cnt << endl;
}


#include <bits/stdc++.h>

using namespace std;
long long a[100005];
int main()
{
    long long n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    sort(a,a+n);
    long long j=n-1;
    for(long long i=(n/2) -1;i>=0;i--)
    {
        if(a[i]*2<=a[j])
        {
            j--;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long a[1000000];
int main()
{
    long long n;
    cin>>n;
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long j=n-1;
    for(long long i=n / 2 - 1;i>=0;i--)
    {
        if(a[i]*2<=a[j])
        {
            --j;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long a[100005];
int main()
{
    long long n;
    cin>>n;
    for(long long i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long j=n-1;
    for(long long i=n / 2 - 1;i>=0;i--)
    {
        if(a[i]*2<=a[j])
        {
            --j;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    sort(a,a+n);
    int j=n-1;
    for(int i=(n/2) -1;i>=0;i--)
    {
        if(a[i]*2<=a[j])
        {
            j--;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]*2<=a[n-1-i])
        {
            c++;
        }
    }
    cout<<n-c<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
long long a[100005];
int main()
{
    long long n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long j=n-1;
    for(long long i=n / 2 - 1;i>=0;i--)
    {
        if(a[i]*2<=a[j])
        {
            --j;
        }
    }
    cout<<j+1<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int c=0;
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(a[i]*2>a[n-1])
        {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include <cstdio>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 500100

ll n, a[2*N], t[4*N], res, ans, used[2*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = max(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return -(ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return max(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	scanf("%lld", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	build(1, 0, 5*N-1);
	int q = n/2;
	ll ans= n;
	for(int i = 0; i < n/2; i++){
		int r = q;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, q, r);
			if(a[i]*2ll <= x && used[r] == 0 && used[i] == 0){
				//cout <<a[i] << ' ' << a[r]<< endl;
				ans--;
				q++;
				f = 1;
				break;
		   	}
			r++;
		}
		if(f) used[i] = used[r] = 1;
	}
	printf("%lld",ans);
	return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 100100

ll n, a[5*N], t[20*N], res, ans, used[5*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = max(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return -(ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return max(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	build(1, 0, 5*N-1);
	int q = n/2;
	ll ans= n;
	for(int i = 0; i < n/2; i++){
		int r = q;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, q, r);
			if(a[i]*2ll <= x && used[r] == 0 && used[i] == 0){
				//cout <<a[i] << ' ' << a[r]<< endl;
				ans--;
				f = 1;
				break;
		   	}
			r++;
		}
		if(f) used[i] = used[r] = 1;
	}
	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll n, a[500500];

int main(){
    cin >> n;
    ll ans = n;
    int mid = n/2;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    for(int i = 0; i < n/2; i++){
    	while(true){
    		if(a[i]*2ll<=a[mid]){
    			ans--;
    			mid++;
    			break;
    		}
    		else{
    			mid++;
    		}
    		if(mid == n) break;
    	}
    }
    cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll n, a[500500];

int main(){
    cin >> n;
    ll ans = n;
    int mid = n/2;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a,a+n);
    for(int i = 0; i < n/2; i++){
    	while(true){
    		if(a[i]*2ll<=a[mid]){
    			ans--;
    			mid++;
    			break;
    		}
    		else{
    			mid++;
    		}
    		if(mid == n) break;
    	}
    	if(mid == n) break;
    }
    cout << ans;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 100100

ll n, a[5*N], used[5*N], res, ans;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	for(int i = 0; i < n; i++){
		if(used[i] == 0){
			int j = i;
			while(j < n){
				if(a[i]*2ll <= a[j]) break;
				j++;
			}
			if(a[i]*2ll <= a[j]) used[i] = used[j] = 1;
		}
	}
	for(int i = 0; i < n; i++){
		res+=(used[i]);
		ans+=(!used[i]);
	}
	cout << res/2 + ans - 1;
	return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 100100

ll n, a[5*N], t[20*N], res, ans, used[5*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = max(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return -(ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return max(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	build(1, 0, 5*N-1);
	int q = n/2;
	ll ans= n;
	for(int i = 0; i < n/2; i++){
		int r = q;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, q, r);
			if(a[i]*2ll <= x && used[r] == 0 && used[i] == 0){
				cout <<a[i] << ' ' << a[r]<< endl;
				ans--;
				f = 1;
				break;
		   	}
			r++;
		}
		if(f) used[i] = used[r] = 1;
	}
	cout << ans;
	return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include <cstdio>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 500100

ll n, a[2*N], t[4*N], res, ans, used[2*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = max(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return -(ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return max(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	scanf("%lld", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	build(1, 0, 5*N-1);
	int q = n/2;
	ll ans= n;
	for(int i = 0; i < n/2; i++){
		int r = q;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, q, r);
			if(a[i]*2ll <= x && used[r] == 0 && used[i] == 0){
				//cout <<a[i] << ' ' << a[r]<< endl;
				ans--;
				q++;
				f = 1;
				break;
		   	}
			r++;
			q++;
		}
		if(f) used[i] = used[r] = 1;
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 100100

ll n, a[5*N], t[20*N], res, ans, used[5*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = min(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return (ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return min(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	build(1, 0, 5*N-1);

	for(int i = 0; i < n; i++){
		int r = i+1;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, i+1, r);
			if(a[i] >= 2ll*x && used[r] == 0 && used[i] == 0){
			//	cout << a[i] << ' ' << a[r] << endl;
				f = 1;
				break;
		   	}
			r++;
		}
		if(f) used[i] = used[r] = 1;
	}
	for(int i = 0; i < n; i++){
	//	cout << a[i] << ' ';
	//	if(used[i]) cout << a[i] << ' ';
		res+=(used[i]);
		ans+=(!used[i]);
	}
	cout << res/2 + ans;
	return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 100100

ll n, a[5*N], t[20*N], res, ans, used[5*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = max(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return -(ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return max(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	scanf("%lld", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	build(1, 0, 5*N-1);
	int q = n/2;
	ll ans= n;
	for(int i = 0; i < n/2; i++){
		int r = q;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, q, r);
			if(a[i]*2ll <= x && used[r] == 0 && used[i] == 0){
				//cout <<a[i] << ' ' << a[r]<< endl;
				ans--;
				f = 1;
				break;
		   	}
			r++;
		}
		if(f) used[i] = used[r] = 1;
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll n, a[500500];

int main(){
    cin >> n;
    ll ans = n;
    int mid = n/2;
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int i = 0; i < n/2; i++){
    	while(true){
    		if(a[i]*2ll<=a[mid]){
    			ans--;
    			mid++;
    			break;
    		}
    		else{
    			mid++;
    		}
    		if(mid == n) break;
    	}
    }
    cout << ans;
	return 0;
}


#include <iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include <cstdio>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
#define N 100100

ll n, a[5*N], t[20*N], res, ans, used[5*N];

void build(int v, int l, int r){
	if(l == r){
		t[v] = a[l];
		return;
	}
	int mid = (l+r)>>1;
	build(v+v, l, mid);
	build(v+v+1, mid+1, r);
	t[v] = max(t[v+v], t[v+v+1]);
}

ll get_MAX(int v, int tl, int tr, int l, int r){
	if(l > r) return -(ll)(1e9)+7;
	if(l == tl && r == tr) return t[v];
	int mid = (tl+tr)>>1;
	return max(get_MAX(v+v, tl, mid, l, min(r,mid)), get_MAX(v+v+1, mid+1, tr, max(l, mid+1), r));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	scanf("%lld", &n);
	for(int i = 0; i < n; i++){
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	build(1, 0, 5*N-1);
	int q = n/2;
	ll ans= n;
	for(int i = 0; i < n/2; i++){
		int r = q;
		bool f = false;
		while(true){
			if(r >= n) break;
			ll x = get_MAX(1, 0, 5*N-1, q, r);
			if(a[i]*2ll <= x && used[r] == 0 && used[i] == 0){
				//cout <<a[i] << ' ' << a[r]<< endl;
				ans--;
				q++;
				f = 1;
				break;
		   	}
			r++;
		}
		if(f) used[i] = used[r] = 1;
	}
	printf("%lld",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,s[500005];
    cin>>n;
    for (int i=1; i<=n; i++) cin>>s[i];
    sort(s+1,s+n+1);
    int mid=(n+1)/2,x=1,mx=n;
    while (mid!=n) {
        if (s[x]*2<=s[mid+1]) mx--,x++;
         mid++;
    }
    cout<<mx;
}

/*
int main() {
    int n,s[500005];
    bool flag=0;
    cin>>n;
    for (int i=1; i<=n; i++) cin>>s[i];
    sort(s+1,s+n+1);
    int lo=0,hi=n/2,mid,ans;
    while (lo<=hi) {
        mid=lo+(hi-lo+1)/2;  //atau (lo+hi)/2 , (hi-lo+1)/2 +1 to prevent infinite loop (rounding bug)
        for (int i=1; i<=mid; i++) {
            if (s[i]*2>s[n-mid+i]) {hi=mid-1; flag=1; }
        }
        if (flag==0) lo=mid+1,ans=mid;
        flag=0;
    }
    cout<<n-ans<<"\n";
}
*/


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,s[500005];
    bool flag=0;
    cin>>n;
    for (int i=1; i<=n; i++) cin>>s[i];
    sort(s+1,s+n+1);
    int lo=0,hi=n,mid,ans;
    while (lo<=hi) {
        mid=(lo+hi)/2;
        for (int i=1; i<=mid; i++) {
            if (s[i]*2>=s[n-mid+i]) {hi=mid-1; flag=1; }
        }
        if (flag==0) lo=mid+1,ans=mid;
        flag=0;
    }
    cout<<n-ans<<"\n";
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,s[500005];
    bool flag=0;
    cin>>n;
    for (int i=1; i<=n; i++) cin>>s[i];
    sort(s+1,s+n+1);
    int lo=0,hi=n/2,mid,ans;
    while (lo<=hi) {
        mid=lo+((hi/2)-lo+1)/2;
        for (int i=1; i<=mid; i++) {
            if (s[i]*2>=s[n-mid+i]) {hi=mid-1; flag=1; }
        }
        if (flag==0) lo=mid+1,ans=mid;
        flag=0;
    }
    cout<<n-ans<<"\n";
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    int n,s[500005];
    bool flag=0;
    cin>>n;
    for (int i=1; i<=n; i++) cin>>s[i];
    sort(s+1,s+n+1);
    int lo=0,hi=n,mid,ans;
    while (lo<=hi) {
        mid=lo+(hi-lo+1)/2;
        for (int i=1; i<=mid; i++) {
            if (s[i]*2>=s[n-mid+i]) {hi=mid-1; flag=1; }
        }
        if (flag==0) lo=mid+1,ans=mid;
        flag=0;
    }
    cout<<n-ans<<"\n";
}