/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . ___
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         佛祖保佑       永无BUG
*/
//use readint!
#pragma GCC optimize(1)
#pragma G++ optimize(1)
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#pragma GCC optimize(3)
#pragma G++ optimize(3)
#pragma GCC optimize(4)
#pragma G++ optimize(4)
#pragma GCC optimize(5)
#pragma G++ optimize(5)
#pragma GCC optimize(6)
#pragma G++ optimize(6)
#pragma GCC optimize(7)
#pragma G++ optimize(7)
#pragma GCC optimize(8)
#pragma G++ optimize(8)
#pragma GCC optimize(9)
#pragma G++ optimize(9)
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#include<map>
#include<iostream>
#include<iomanip>
//#include<conio.h>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<assert.h>
#include<time.h>
#include<queue>
#include<deque>
#include<stack>
#include<list>
//#include<windows.h>
#include<sstream>
#include<string.h>
#define mp make_pair
#define ll long long
#define all(v) v.begin(),v.end()
#define memset(a,b) memset(a,b,sizeof(a))
using namespace std;
const int INF=2147483647;
const double PI=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781857780532171226806613001927876611195909216420198938095257201065485863278865936153381827968230301952;
const int maxn=10005;
struct bign{
    int d[maxn], len;
    inline void clean() { while(len > 1 && !d[len-1]) len--; }
    inline bign()          { memset(d, 0); len=1; }
    inline bign(int num)   { *this=num; }
    inline bign(char* num) { *this=num; }
    inline bign operator=(const char* num){
        memset(d, 0); len=strlen(num);
        for(int i=0; i<len; i++) d[i]=num[len-1-i] - '0';
        clean();
        return *this;
    }
    inline bign operator=(int num){
        char s[20]; sprintf(s, "%d", num);
        *this=s;
        return *this;
    }
    inline bign operator + (const bign& b){
        bign c=*this; int i;
        for (i=0; i<b.len; i++){
            c.d[i] +=b.d[i];
            if (c.d[i] > 9) c.d[i]%=10, c.d[i+1]++;
        }
        while (c.d[i] > 9) c.d[i++]%=10, c.d[i]++;
        c.len=max(len, b.len);
        if (c.d[i] && c.len<=i) c.len=i+1;
        return c;
    }
	inline bign operator - (const bign& b){
        bign c=*this; int i;
        for (i=0; i<b.len; i++){
            c.d[i] -=b.d[i];
            if (c.d[i]<0) c.d[i]+=10, c.d[i+1]--;
        }
        while (c.d[i]<0) c.d[i++]+=10, c.d[i]--;
        for(i=c.len-1;i>0;i--) if(c.d[i]!=0) break;
        c.len=i+1;
//      c.clean();
        return c;
    }
    inline bign operator * (const bign& b)const{
        int i, j; bign c; c.len=len + b.len;
        for(j=0; j<b.len; j++) for(i=0; i<len; i++)
            c.d[i+j] +=d[i] * b.d[j];
        for(i=0; i<c.len-1; i++)
            c.d[i+1] +=c.d[i]/10, c.d[i] %=10;
        c.clean();
        return c;
    }
    inline bign operator / (const bign& b){
        int i, j;
        bign c=*this, a=0;
        for (i=len - 1; i >=0; i--)
        {
            a=a*10 + d[i];
            for (j=0; j<10; j++) if (a<b*(j+1)) break;
            c.d[i]=j;
            a=a - b*j;
        }
        c.clean();
        return c;
    }
    inline bign operator % (const bign& b){
        int i, j;
        bign a=0;
        for (i=len-1;i>=0;i--){
            a=a*10 + d[i];
            for (j=0; j<10; j++) if (a<b*(j+1)) break;
            a=a - b*j;
        }
        return a;
    }
    inline bign operator += (const bign& b){
        *this=*this + b;
        return *this;
    }
    inline bign operator *= (const bign& b){
    	*this=*this * b;
    	return *this;
	}
	inline bign operator -= (const bign& b){
		*this=*this - b;
		return *this;
	}
	inline bign operator /= (const bign& b){
		*this=*this / b;
		return *this;
	}
    inline bool operator < (const bign& b) const{
        if(len !=b.len) return len<b.len;
        for(int i=len-1; i >=0; i--)
            if(d[i] !=b.d[i]) return d[i]<b.d[i];
        return false;
    }
    inline bool operator >(const bign& b) const{return b<*this;}
    inline bool operator<=(const bign& b) const{return !(b<*this);}
    inline bool operator>=(const bign& b) const{return !(*this<b);}
    inline bool operator!=(const bign& b) const{return b<*this || *this<b;}
    inline bool operator==(const bign& b) const{return !(b<*this) && !(b > *this);}
    inline string str() const{
        char s[maxn]={};
        for(int i=0; i<len; i++) s[len-1-i]=d[i]+'0';
        return s;
    }
};

inline istream& operator >>(istream& in, bign& x)
{
    string s;
    in>>s;
    x=s.c_str();
    return in;
}

inline ostream& operator << (ostream& out, const bign& x)
{
    out<<x.str();
    return out;
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void rd(long long &val){
    long long x=0;
    int f=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    val=x*f;
}
inline void rd(int &val){
    int x=0;
    int f=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-'){
		f=-1;
		ch=getchar();
	}
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    val=x*f;
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
int fa[1111],n;
bool use[1111];
inline void dfs(int x){
	if(use[x]){
		cout<<x<<' ';
		return;
	}
	use[x]=1;
	dfs(fa[x]);
}
int main(){
	ios_base::sync_with_stdio(false);
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++) cin>>fa[i];
	for(i=1;i<=n;i++) memset(use,0),dfs(i);
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int n,ans;
int a[1003];
int f[1003];
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-') f=-f;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
void dfs(int k)
{
    if(f[k]==2) {
        ans=k;
        return ;
    }
    f[k]++;
    dfs(a[k]);
    f[k]--;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<=n;i++)
    {
        dfs(i);
        cout<<ans<<" ";
    }
}


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

}


#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;
int p[1005];
int book[1005]={0};
int pan(int x)
{
    memset(book,0,sizeof(book));
    int now=x;
    while(1)
    {
        book[now]++;
        now=p[now];
        if(book[now]==2)return now;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<pan(i)<<" ";
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1005
int n;
int a[maxn];
bool vis[maxn];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
    for(int i=1;i<=n;i++){
    	memset(vis,0,sizeof(vis));
    	int now=i;
    	while(!vis[now]){
    		vis[now]=true;
    		now=a[now];
    	}
    	cout<<now<<" ";
    }
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1005
int n;
int a[maxn];
bool vis[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		memset(vis,false,sizeof(vis));
		vis[i]=true;
//		for(int j=1;j<=n;j++){
//			if(vis[a[j]]){
//				cout<<a[j]<<" ";
//				break;
//			}
//			vis[a[i]]=true;
//		}
		for(int j=1;j<=n;j++){
			if(vis[a[j]]){
				cout<<a[j]<<" ";
				break;
			}
			vis[a[j]]=true;
		}
	}
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1005
int n;
int a[maxn];
bool vis[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		memset(vis,false,sizeof(vis));
		if(a[1]!=i)vis[i]=true;
//		for(int j=1;j<=n;j++){
//			if(vis[a[j]]){
//				cout<<a[j]<<" ";
//				break;
//			}
//			vis[a[i]]=true;
//		}
		for(int j=1;j<=n;j++){
			if(vis[a[j]]){
				cout<<a[j]<<" ";
				break;
			}
			vis[a[j]]=true;
		}
	}
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1005
int n;
int a[maxn];
bool vis[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		memset(vis,false,sizeof(vis));
		vis[i]=true;
		for(int j=1;j<=n;j++){
			if(vis[a[j]]){
				cout<<a[j]<<" ";
				break;
			}
			vis[a[i]]=true;
		}
	}
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1005
int n;
int a[maxn];
bool vis[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	bool mark=true;
	for(int i=1;i<=n;i++){
		memset(vis,false,sizeof(vis));
		if(a[1]!=i)vis[i]=true;
		mark=false;
		for(int j=1;j<=n;j++){
			if(vis[a[j]]){
				cout<<a[j]<<" ";
				mark=true;
				break;
			}
			vis[a[j]]=true;
		}
		if(!mark)
		cout<<a[1]<<" ";
	}
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1005
int n;
int a[maxn];
bool vis[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	bool mark=true;
	for(int i=1;i<=n;i++){
		memset(vis,false,sizeof(vis));
	   vis[i]=true;
		mark=false;
		for(int j=1;j<=n;j++){
			if(vis[a[j]]){
				cout<<a[j]<<" ";
				mark=true;
				break;
			}
			vis[a[j]]=true;
		}
		if(!mark)
		cout<<a[1]<<" ";
	}
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> a(n,0);

	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	int next;
	for (int i = 0; i < n; i++) {
		next = i;
		while(true) {
			// cout << next << endl;
			a[next]++;
			// cout << a[next] << endl;
			if (a[next] > 1) {
				cout << next + 1 << " ";
				break;
			}
			next = v[next] - 1;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	vector<int> a(n,0);

	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	int next;
	for (int i = 0; i < n; i++) {
		next = i;
		while(true) {
			// cout << next << endl;
			a[next]++;
			// cout << a[next] << endl;
			if (a[next] > 1) {
				cout << next + 1 << " ";
				break;
			}
			next = v[next] - 1;
		}
		fill(a.begin(), a.end(), 0);
	}

	return 0;
}


#include <iostream>

using namespace std;

void solve(int n,int*p,int *c,int *ans,int a){
    if(c[a]>1){
        *ans=a;
        return;}
    c[a]++;
    solve(n,p,c,ans,p[a-1]);
}

int main()
{   int n=0;
    cin >> n;
    int p[n];

    for(int i=0;i<n;i++){
        cin >>p[i];
    }

    for(int i=1;i<=n;i++){
        int c[1005]={0};
        int ans=-1;
        solve(n,p,c,&ans,i);
        cout << ans <<" ";
    }
    return 0;
}


#include <iostream>

using namespace std;

void solve(int n,int*p,int *c,int *ans,int a){
    if(c[a]>1){
        *ans=a;
        return;}
    c[a]++;
    solve(n,p,c,ans,p[a-1]);
}

int main()
{   int n=0;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++){
        cin >>p[i];
    }

    for(int i=1;i<=n;i++){
        int c[1000]={0};
        int ans=-1;
        solve(n,p,c,&ans,i);
        cout << ans <<" ";
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,g[10005],f[10005],ans[10005];
bool f1[10005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&g[i]);
	for(int i=1;i<=n;i++)
		if(!ans[i])
		{
			int tot=1;
			f[tot]=i;
			f1[i]=1;
			int x=i;
			while(1)
			{
				int v=g[x];
				if(ans[v])
				{
					for(int i=tot;i>=1;i--)
					{
						ans[f[i]]=ans[v];
						f1[f[i]]=0;
					}
					break;
				}
				if(f1[v])
				{
					bool ff=0;
					for(int i=tot;i>=1;i--)
					{
						if(!ff)
							ans[f[i]]=f[i];
						else
							ans[f[i]]=v;
						if(f[i]==v)
							ff=1;
						f1[f[i]]=0;
					}
					break;
				}
				f1[v]=1;
				x=v;
				f[++tot]=v;
			}
		}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,g[10005],f[10005],ans[10005];
bool f1[10005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&g[i]);
	for(int i=1;i<=n;i++)
		if(!ans[i])
		{
			int tot=1;
			f[tot]=i;
			f1[i]=1;
			int x=i;
			while(1)
			{
				int v=g[x];
				if(ans[v])
				{
					for(int i=tot;i>=1;i--)
					{
						ans[f[i]]=v;
						f1[f[i]]=0;
					}
					break;
				}
				if(f1[v])
				{
					bool ff=0;
					for(int i=tot;i>=1;i--)
					{
						if(!ff)
							ans[f[i]]=f[i];
						else
							ans[f[i]]=v;
						if(f[i]==v)
							ff=1;
						f1[f[i]]=0;
					}
					break;
				}
				f1[v]=1;
				x=v;
				f[++tot]=v;
			}
		}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,g[1005],f[1005],ans[1005];
bool f1[1005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&g[i]);
	if(n==1)
	{
		printf("0");
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(!ans[i])
		{
			int tot=1;
			f[tot]=i;
			f1[i]=1;
			int x=i;
			while(1)
			{
				int v=g[x];
				if(f1[v])
				{
					bool ff=0;
					for(int i=tot;i>=1;i--)
					{
						if(!ff)
							ans[f[i]]=f[i];
						else
							ans[f[i]]=v;
						if(f[i]==v)
							ff=1;
						f1[f[i]]=0;
					}
					break;
				}
				if(ans[v])
				{
					for(int i=tot;i>=1;i--)
					{
						ans[f[i]]=v;
						f1[f[i]]=0;
					}
					break;
				}
				f1[v]=1;
				x=v;
				f[++tot]=v;
			}
		}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,g[10005],f[10005],ans[10005];
bool f1[10005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&g[i]);
	if(n==1)
	{
		printf("1");
		return 0;
	}
	for(int i=1;i<=n;i++)
		if(!ans[i])
		{
			int tot=1;
			f[tot]=i;
			f1[i]=1;
			int x=i;
			while(1)
			{
				int v=g[x];
				if(ans[v])
				{
					for(int i=tot;i>=1;i--)
					{
						ans[f[i]]=v;
						f1[f[i]]=0;
					}
					break;
				}
				if(f1[v])
				{
					bool ff=0;
					for(int i=tot;i>=1;i--)
					{
						if(!ff)
							ans[f[i]]=f[i];
						else
							ans[f[i]]=v;
						if(f[i]==v)
							ff=1;
						f1[f[i]]=0;
					}
					break;
				}
				f1[v]=1;
				x=v;
				f[++tot]=v;
			}
		}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,g[1005],f[1005],ans[1005];
bool f1[1005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&g[i]);
	for(int i=1;i<=n;i++)
		if(!ans[i])
		{
			int tot=1;
			f[tot]=i;
			f1[i]=1;
			int x=i;
			while(1)
			{
				int v=g[x];
				if(f1[v])
				{
					bool ff=0;
					for(int i=tot;i>=1;i--)
					{
						if(!ff)
							ans[f[i]]=f[i];
						else
							ans[f[i]]=v;
						if(f[i]==v)
							ff=1;
						f1[f[i]]=0;
					}
					break;
				}
				if(ans[v])
				{
					for(int i=tot;i>=1;i--)
					{
						ans[f[i]]=v;
						f1[f[i]]=0;
					}
					break;
				}
				f1[v]=1;
				x=v;
				f[++tot]=v;
			}
		}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define maxn 1005
int a[maxn];
int b[maxn];
using namespace std;
int main()
{
    int n,t;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        memset(b,0,sizeof(b));
        t=i;
      while(1)
      {
          b[t]++;
            if(b[t]>=2)
                {
                    printf("%d ",t);
                    break;
                }
            t=a[t];
     }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define maxn 1005
int a[maxn];
int b[maxn];
using namespace std;
int main()
{
    int n;
    memset(b,0,sizeof(b));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        memset(b,0,sizeof(b));
        b[i]++;
        for(int j=1;j<=n;j++)
        {
            b[a[j]]++;
            if(b[a[j]]>=2)
                {
                    printf("%d ",a[j]);
                    break;
                }
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define maxn 1005
int a[maxn];
int b[maxn];
using namespace std;
int main()
{
    int n;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        memset(b,0,sizeof(b));
        b[i]++;
        for(int j=1;j<=n;j++)
        {
            b[a[j]]++;
            if(b[a[j]]>=2)
                {
                    printf("%d ",a[j]);
                    break;
                }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

const int MaxN = 1e3 + 5;
typedef long long LL;
vector<int> G[MaxN];
int vis[MaxN], f[MaxN], edg[MaxN][MaxN];

void dfs(int x){
	int now, next;
	for(int i = 0; i < (int)G[x].size(); i++){
		next = G[x][i];
		if(f[edg[x][next]] == 0){
			f[edg[x][next]] = 1;
			vis[next]++;
			//cout<<"("<<next<<")";
			dfs(next);
		}
	}
	return;
}
int main(){
	int n;
	cin>>n;
	for(int i = 1; i <= n; i++){
		int x;
		cin>>x;
		G[i].push_back(x);
		edg[i][x] = i;
	}
	for(int i = 1; i <= n; i++){
		memset(vis, 0, sizeof(vis));
		memset(f, 0, sizeof(f));
		dfs(i);
		vis[i]++;
		//cout<<"***"<<endl;
		for(int j = 1; j <= n; j++){
			if(vis[j] == 2)	cout<<j<<" ";
		}
	}
	cout<<endl;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

const int MaxN = 1e4 + 5;
typedef long long LL;
vector<int> G[MaxN];
int vis[MaxN], f[MaxN], ind[MaxN], edg[MaxN][MaxN];

void dfs(int x){
	int now, next;
	for(int i = 0; i < (int)G[x].size(); i++){
		next = G[x][i];
		if(f[edg[x][next]] == 0){
			f[edg[x][next]] = 1;
			vis[next]++;
			//cout<<"("<<next<<")";
			dfs(next);
		}
	}
	return;
}
int main(){
	int n;
	cin>>n;
	for(int i = 1; i <= n; i++){
		int x;
		cin>>x;
		G[i].push_back(x);
		edg[i][x] = i;
	}
	for(int i = 1; i <= n; i++){
		memset(vis, 0, sizeof(vis));
		memset(f, 0, sizeof(f));
		dfs(i);
		vis[i]++;
		//cout<<"***"<<endl;
		for(int j = 1; j <= n; j++){
			if(vis[j] == 2)	cout<<j<<" ";
		}
	}
	cout<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int p[n+2];
        for(int i=1;i<=n;i++)
        {
            cin>> p[i];
        }
        vector<int> vec;
        for(int i=1;i<=n;i++)
        {
            bool mark[1000]={false};
            int g = i;
            while(1)
            {
                //cout << "baire: g: " <<g <<" p[g]: "<<p[g]<<endl;

                if(mark[p[g]]){
                    // cout << "p[g]: "<< p[g] << " g: " << g << endl;
                vec.push_back(p[g]);break;}
                else
                {
                    mark[g] = true;
                    g = p[g];
                }

            }
        }
        for(int i=0;i<vec.size();i++)
            cout << vec[i] <<" ";
        cout << endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int p[n+2];
        for(int i=1;i<=n;i++)
        {
            cin>> p[i];
        }
        vector<int> vec;
        for(int i=1;i<=n;i++)
        {
            bool mark[1006]={false};
            int g = i;
            while(1)
            {
                //cout << "baire: g: " <<g <<" p[g]: "<<p[g]<<endl;

                if(mark[p[g]]){
                  //   cout << "p[g]: "<< p[g] << " g: " << g << endl;
                vec.push_back(p[g]);break;}
                else
                {
                    mark[g] = true;
                    g = p[g];
                }

            }
        }
        for(int i=0;i<vec.size();i++)
            cout << vec[i] <<" ";
        cout << endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int p[n+2];
        for(int i=1;i<=n;i++)
        {
            cin>> p[i];
        }
        vector<int> vec;
        for(int i=1;i<=n;i++)
        {
            bool mark[1006]={false};
            int g = i;
            while(1)
            {
                cout << "baire: g: " <<g <<" p[g]: "<<p[g]<<endl;

                if(mark[p[g]]){
                     cout << "p[g]: "<< p[g] << " g: " << g << endl;
                vec.push_back(p[g]);break;}
                else
                {
                    mark[g] = true;
                    g = p[g];
                }

            }
        }
        for(int i=0;i<vec.size();i++)
            cout << vec[i] <<" ";
        cout << endl;

    }
    return 0;
}


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

int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int b[n]={0};
	for(int i=0;i<n;i++)
	{
		int stu=i;
		while(1)
		{
			b[stu]++;
			if(b[stu]>1)
			{
				cout<<stu+1<<" ";
				break;
			}
			stu=a[stu]-1;
		}
	}
}


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

int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int b[n]={0};
	for(int i=0;i<n;i++)
	{
		int stu=i;
		while(1)
		{
			b[stu]++;
			if(b[stu]>1)
			{
				cout<<stu+1<<" ";
				break;
			}
			stu=a[stu]-1;
		}
		for(int i=0;i<n;i++)
			b[i]=0;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);
#define mx 100000
#define F first
#define S second
//#define pb push_back

int main()
{
    faster_io;
    int n,i,k,j;
    cin>>n;
    int p[n+5],a[n+5];

    for(i=1;i<=n;i++) cin>>a[i];

    for(j=1;j<=n;j++){
        vector<int> g[n+5];
        g[j].push_back(j);
        for(i=j;i<=n;i=a[i]){
            g[a[i]].push_back(i);
            //cout<<a[i]<<" ";
            if(g[a[i]].size()==2) break;
        }
        cout<<a[i]<<" ";
        //for(k=1;k<=n;k++) g[k].clear();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);
#define mx 100000
#define F first
#define S second
//#define pb push_back

int main()
{
    faster_io;
    int n,i,k,j;
    cin>>n;
    int p[n+5],a[n+5];

    for(i=1;i<=n;i++) cin>>a[i];

    for(j=1;j<=n;j++){
        vector<int> g[n+5];
        g[j].push_back(j);
        for(i=1;i<=n;i++){
            g[a[i]].push_back(i);
            //cout<<a[i]<<" ";
            if(g[a[i]].size()==2) break;
        }
        cout<<a[i]<<" ";
        //for(k=1;k<=n;k++) g[k].clear();
    }
    return 0;
}


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

void rep(char a[])
{
    int i,j;
    for(i=0;a[i];i++)
    {
        for(j=i+1;a[j];j++)
        {
            if(a[i]==a[j])
            {
                printf("%c ",a[i]);
                return;
            }

        }
    }
}
int main()
{
    int n,i;
    scanf("%d",&n);
    char a[1010];
    for(i=1;i<n+1;i++)
    {
       cin>>a[i];
    }
    a[i]='\0';
    i=1;
    while(n--)
    {

        a[0]=(i++)+'0';
        rep(a);
    }
    printf("\n");
}


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

void rep(int arr[], int n)
{
    int min = -1;
    set<int> myset;
    for (int i = n - 1; i >= 0; i--)
    {
        if (myset.find(arr[i]) != myset.end())
            min=i;
        else
            myset.insert(arr[i]);
    }
    if (min != -1)
        cout << arr[min]<<" "
        ;

}
int main()
{
    int n,i;
    scanf("%d",&n);
    int k=n+1;
    int a[1010];
    for(i=1; i<n+1; i++)
    {
        cin>>a[i];
    }
    i=1;
    while(n--)
    {
        a[0]=(i++);
        //printf("k=%d a[0]=%d\n",k,a[0]);

        rep(a,k);
    }
    printf("\n");
}


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

void rep(int a[],int n)
{
    int i,j;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]==a[j])
            {
                printf("%d ",a[i]);
                return;
            }

        }
    }
}
int main()
{
    int n,i;
    scanf("%d",&n);
    int k=n;
    int a[1010];
    for(i=1;i<n+1;i++)
    {
       cin>>a[i];
    }
    i=1;
    while(n--)
    {

        a[0]=(i++);
        rep(a,k+1);
    }
    printf("\n");
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
inline int read() {
    int res=0;char c=getchar();bool f=0;
    while(!isdigit(c)) {if(c=='-')f=1;c=getchar();}
    while(isdigit(c))res=(res<<3)+(res<<1)+(c^48),c=getchar();
    return f?-res:res;
}
#define reg register
int n;
int p[1005];
bool vis[1005];

int main()
{
	n = read();
	for (reg int i = 1 ; i <= n ; i ++) p[i] = read();
	for (reg int i = 1 ; i <= n ; i ++)
	{
		memset(vis, 0, sizeof vis);
		int k = i;
		while(!vis[k])
		{
			vis[k] = 1;
			k = p[k];
		}
		printf("%d ", k);
	}
	return 0;
}


#include <iostream>

using namespace std;
const int maxn = 1000+5;
int arr[maxn];
int book[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for(int i=1;i<=n;i++){
        int j=i;
        while(book[j]!=i){
            book[j]=i;
            j=arr[j];
        }
        cout<<j<<" ";
    }
    return 0;
}


/**#include <iostream>

using namespace std;
const int maxn = 1000+5;
int arr[maxn];
int book[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for(int i=1;i<=n;i++){
        int j=i;
        while(book[j]!=i){
            book[j]=i;
            j=arr[j];
        }
        cout<<j<<" ";
    }
    return 0;
}*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <memory.h>
#define MAXN 1005
using namespace std;

int x[MAXN];
int y[MAXN];

int main(){
    int n, p;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=n;i++){
        memset(y,0,sizeof(y));
        y[i]++;
        p=x[i];
        while(1){
            y[p]++;
            if(y[p]>=2){
                cout<<p<<" ";
                break;
            }
            p=x[p];
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <memory.h>
#define MAXN 1005
using namespace std;

int x[MAXN];
int y[MAXN];

int main(){
    int n, p;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x[i];
    }
    for(int i=1;i<=n;i++){
        y[i]++;
        p=x[i];
        while(1){
            y[p]++;
            if(y[p]>=2){
                cout<<p<<" ";
                break;
            }
            p=x[p];
        }
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,p[1100];
bool k[1100],flag;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    for(int i=1;i<=n;i++){
        memset(k,0,sizeof(k));
        int r=i;
        k[r]=1,flag=0;
        while(flag==0){
            r=p[r];
            if(k[r]==0){
                k[r]=1;
            }
            else{
                cout<<r<<" ";
                flag=1;
            }
        }
    }
    return 0;
}


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

#define fo(n) for(int i=0;i<n;i++)
#define lop(k,n) for(int i=k;i<=n;i++)
#define ll long long int
//printf("%.15f\n", ans)f

int main(){

int n,p,ans=0,a[1002],h[1002]={0};
set<int> c;

cin>>n;
lop(1,n){cin>>a[i];}
lop(1,n){p=i;
 while(!c.count(p)){c.insert(p);p=a[p];}
 h[i]=p ;
 c.clear();
}
fo(n)cout<<h[i+1]<<" ";
return 0;}


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

#define fo(n) for(int i=0;i<n;i++)
#define lop(k,n) for(int i=k;i<=n;i++)
#define ll long long int
//printf("%.15f\n", ans)f

int main(){

int n,p,ans=0,a[1002],h[1002]={0};
set<int> c;

cin>>n;
lop(1,n){cin>>a[i];}
lop(1,n){p=i;
 while(!c.count(a[p])){c.insert(p);p=a[p];}
 h[i]=a[p];
 c.clear();
}
fo(n)cout<<h[i+1]<<" ";
return 0;}


#include<stdio.h>
#include<vector>
using namespace std;

int b[1010];
int a[1010];
int c[1010];
bool vis[1010];
vector<int> v[1010];

void dfs(int x,int y,int hu){

	if (b[x]!=0 && x!=y)
	return ;

	c[x]=y;
	b[x]=hu;
	for (int i=0;i<v[x].size();i++){
		dfs(v[x][i],y,hu);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		v[i].clear();
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=0;
		vis[i]=false;
		if (a[i]!=i)
		v[a[i]].push_back(i);
	}
	int hu=0;
	for (int i=1;i<=n;i++){
		if (vis[i]){
			continue;
		}
		int x=i;
		while (!vis[x]){
			vis[x]=true;
			x=a[x];
	//		printf("%d %d\n",i,x);
		}
		if (b[x]!=0){
			continue;
		}
	//	printf("%d %d\n",x,b[x]);
		hu++;
		int pp=0;
		while (b[x]!=hu){
			b[x]=hu;
			x=a[x];
			pp++;
		}
		for (int j=1;j<=pp;j++){
			dfs(x,x,hu);
			x=a[x];
//			printf("\n");
		}
/*		printf("%d\n",hu);
		for (int i=1;i<=n;i++){
			printf("%d ",b[i]);
		}
		printf("\n");	*/
	}
	for (int i=1;i<=n;i++){
		printf("%d%c",c[i],i==n?'\n':' ');
	}
}

/*
5
3 3 4 5 4
*/


#include<stdio.h>
#include<vector>
using namespace std;

int b[1010];
int a[1010];
int c[1010];
bool vis[1010];
vector<int> v[1010];

void dfs(int x,int y,int hu){

	if (b[x]!=0 && x!=y)
	return ;

	c[x]=y;
	b[x]=hu;
	for (int i=0;i<v[x].size();i++){
		dfs(v[x][i],y,hu);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		v[i].clear();
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=0;
		vis[i]=false;
		v[a[i]].push_back(i);
	}
	int hu=0;
	for (int i=1;i<=n;i++){
		if (vis[i]){
			continue;
		}
		int x=i;
		while (!vis[x]){
			vis[x]=true;
			x=a[x];
	//		printf("%d %d\n",i,x);
		}
		if (b[x]!=0){
			continue;
		}
	//	printf("%d %d\n",x,b[x]);
		hu++;
		int pp=0;
		while (b[x]!=hu){
			b[x]=hu;
			x=a[x];
			pp++;
		}
		for (int j=1;j<=pp;j++){
			dfs(x,x,hu);
			x=a[x];
//			printf("\n");
		}
/*		printf("%d\n",hu);
		for (int i=1;i<=n;i++){
			printf("%d ",b[i]);
		}
		printf("\n");	*/
	}
	for (int i=1;i<=n;i++){
		printf("%d%c",c[i],i==n?'\n':' ');
	}
}

/*
5
3 3 4 5 4
*/


#include<bits/stdc++.h>
using namespace std;
int to[1200];
bool vis[1200];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>to[i];
    }
    for(int i=1;i<=n;i++) {
        memset(vis,0,sizeof vis);
        int at=i;
        while(1) {
            if(vis[at]==true) {cout<<at<<" ";break;}
            vis[at]=true;
            at=to[at];
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int to[1200];
bool vis[1200];
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>to[i];
    }
    for(int i=1;i<=n;i++) {
        memset(vis,0,sizeof vis);
        int at=i;
        while(1) {
            if(vis[at]==true) {cout<<at<<" ";break;}
            vis[at]=true;
            at=to[at];
        }
    }
    return 0;
}//888


#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string.h>
using namespace std;
int p[1005];
int book[1005]={0};
int pan(int x)
{
    memset(book,0,sizeof(book));
    int now=x;
    while(1)
    {
        book[now]++;
        now=p[now];
        if(book[now]==2)return now;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<pan(i)<<" ";
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;
int p[1005];
int book[1005]={0};
int pan(int x)
{
    memset(book,0,sizeof(book));
    int now=x;
    while(1)
    {
        book[now]++;
        now=p[now];
        if(book[now]==2)return now;
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&p[i]);
    }
    for(int i=1;i<=n;i++)
    {
        cout<<pan(i)<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
using namespace std;
int a[1005],mp[1005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		memset(mp,0,sizeof mp);
		mp[i]=1;
		for(int j=1;j<=n;j++){
			mp[a[j]]++;
			if(mp[a[j]]==2){
				cout<<a[j]<<' ';
				break;
			}
		}
	}
	cout<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<fstream>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
using namespace std;

int main()
{
//for(;;)
{
    int n;
    cin>>n;
    vector<double>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.rbegin(),v.rend());
    int i=0,j=1;
    for(;;)
    {
        if(v.size()==i||j==v.size())
            break;

        if(v[i]==-1)
            {i++;continue;}
        if(v[i]*0.5>=v[j])
        {
            v[j]=-1;
         i++;j++;n--;
        }
        else
            j++;
    }
    cout<<n<<endl;

}
return 0;
}


#include<iostream>
#include<algorithm>
#include<fstream>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
using namespace std;

int main()
{
//for(;;)
{
    int n;
    cin>>n;
    vector<double>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.rbegin(),v.rend());
    int i=0,j=((n+1)/2);
    for(;;)
    {
        if(v.size()==i||j==v.size())
            break;

        if(v[i]==-1)
            {i++;continue;}
        if(v[i]*0.5>=v[j])
        {
            v[j]=-1;
         i++;j++;n--;
        }
        else
            j++;
    }
    cout<<n<<endl;

}
return 0;
}


#include<iostream>
#include<algorithm>
#include<fstream>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
using namespace std;

int main()
{
//for(;;)
{
    int n;
    cin>>n;
    vector<double>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.rbegin(),v.rend());
    int i=0,j=1;
    for(;;)
    {
        if(v.size()==i||v.size()==j)
            break;
        if(v[i]*0.5>=v[j])
        {
         i++;j++;n--;
        }
        else
            j++;
    }
    cout<<n<<endl;

}
return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#define N 1000100
#define MOD 1000000007
#define LL __int64
using namespace std;
int a[N];
int main() {
	int i,j,k,n,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	m=n/2;
	int ans=0,x,y;
	x=0;
	y=m;
	for(i=0;i<m;i++)
	{
		while(y<n&&a[y]<a[i]*2){
			ans++;
			y++;
		}
		if(y>=n){
			ans++;
			continue;
		}
		ans++;
		y++;

	}
	while(y<n){
		ans++;
		y++;
	}
	printf("%d\n",ans);
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;

#define sz(X) ((int)(X.size()))
#define all(x) x.begin(),x.end()
#define clr(x,c) memset(x,c,sizeof(x))
#define up(i,s,e) for(int i=s;i<e;i++)
#define down(i,s,e) for(int i=s;i>e;i--)
int n;
int input[500005];
int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	cin>>n;
	up(i,0,n){
		scanf("%d",&input[i]);
	}
	sort(input,input+n);
	int i=0;
	int j=n/2+n%2;
	int count = 0;
	while(j<n){
		if(input[i]*2 <= input[j]){
			i++,j++,count++;
		}else{
			j++;
		}
	}
	cout<<n-count<<endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	//freopen ("input.txt","r",stdin);
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		v.push_back (a);
	}
	sort (v.begin(),v.end());
	int middle = v.size () / 2 - 1;
	int end = v.size() - 1;
	int cnt = 0;
	while (middle >= 0 && end > middle)
	{
		if (2 * v[middle] <= v[end])
		{
			cnt++;
			middle--;
			end--;
		}
		else
			middle--;
	}
	cout << v.size() - cnt;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	//freopen ("input.txt","r",stdin);
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		v.push_back (a);
	}
	sort (v.begin(),v.end());
	int middle = v.size () / 2;
	int end = v.size() - 1;
	int cnt = 0;
	while (middle >= 0 && end > middle)
	{
		if (2 * v[middle] <= v[end])
		{
			cnt++;
			middle--;
			end--;
		}
		else
			middle--;
	}
	cout << v.size() - cnt;
	return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int const maxsize=500010;
int n;
int a[maxsize];
bool visit[maxsize];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int minpos=0;
        int maxpos=(n+1)/2;
        int ans=n;
        while(maxpos<n)
        {
            if(2*a[minpos]<=a[maxpos])
            {
                ans--;
                minpos++;maxpos++;
            }
            else maxpos++;
        }
         printf("%d\n",ans);
    }
    return 0;
}


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int const maxsize=500010;
int n;
int a[maxsize];
bool visit[maxsize];
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int minpos=0;
        int maxpos=n/2;
        int ans=n;
        while(maxpos<n)
        {
            if(2*a[minpos]<=a[maxpos])
            {
                ans--;
                minpos++;maxpos++;
            }
            else maxpos++;
        }
         printf("%d\n",ans);
    }
    return 0;
}


//IN THE NAME OF GOD
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <fstream>
#include <utility>
#include <sstream>
#include <list>
#include <iomanip>
#include <functional>
#include <deque>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <climits>
#include <cctype>
#include <cassert>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;

#define timestamp(x) printf("Time : %.8lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define INF 0x3f3f3f3f
#define pii pair < int , int >
#define MP make_pair
#define MOD 1000000007
#define EPS 1e-9
#define MAXN 2000000+10
#define LL long long

int main()
{
    //freopen("i.txt", "r", stdin);
    int n ,ans = 0 ;
    vector < int > num;
    cin >> n;
    num.resize(n);
    for (int i = 0; i < n; i++) cin >> num[i];
    sort(num.begin(), num.end());
    int i = 0 , j = 0;
    for (i; i < num.size()/2; i++){
        for (;num.size()/2 + j<num.size();){
            if (num[i] * 2 <= num[num.size() / 2 + j]){
                j++;
                ans++;
                break;
            }
            else j++;
        }
    }
    cout << num.size() - ans << endl;
    return 0;
}


//IN THE NAME OF GOD
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <fstream>
#include <utility>
#include <sstream>
#include <list>
#include <iomanip>
#include <functional>
#include <deque>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <climits>
#include <cctype>
#include <cassert>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std ;

#define timestamp(x) printf("Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define INF 0x3f3f3f3f
#define pii pair < int , int >
#define MP make_pair
#define MOD 1000000007
#define EPS 1e-9

bitset < 500000+100 > visit ;

int main ()
{
    //freopen ( "i.txt" , "r" , stdin ) ;
    int n , tmp ;
    vector < int > num ;
    cin >> n ;
    while ( n-- ){
        cin >> tmp ;
        num.push_back ( tmp ) ;
    }
    sort ( num.begin() , num.end() ) ;
    int l = num.size()-1 , ans = (int)(num.size()) ;
    for ( int i = num.size()-2 ; i >= 0 ; i-- ){
        if ( visit[i] ) continue ;
        while ( visit[l] ){
            l-- ;
        }
        if ( l == i ) continue ;
        if ( num[l] >= num[i]*2 ){
            visit[i] = visit[l] = 1 ;
            ans-- ;
            if ( abs ( l-i ) == 1 ){
                l = i - 1 ;
                i -= 2 ;
                if ( i == 0 ) i = 1 ;
            }else{
                l-- ;
            }
        }
    }
    cout << ans << endl ;
    return 0 ;
}


//IN THE NAME OF GOD
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <fstream>
#include <utility>
#include <sstream>
#include <list>
#include <iomanip>
#include <functional>
#include <deque>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <climits>
#include <cctype>
#include <cassert>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std;

#define timestamp(x) printf("Time : %.8lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define INF 0x3f3f3f3f
#define pii pair < int , int >
#define MP make_pair
#define MOD 1000000007
#define EPS 1e-9
#define MAXN 2000000+10
#define LL long long

int main()
{
   // freopen("i.txt", "r", stdin);
    int n ,ans = 0 ;
    vector < int > num;
    cin >> n;
    num.resize(n);
    for (int i = 0; i < n; i++) cin >> num[i];
    sort(num.begin(), num.end());
    int i = 0 , j = 0;
    for (i; i < num.size(); i++){
        for (j; j < num.size(); j++){
            if (i == j) continue;
            else if (num[i] * 2 <= num[j]){
                ans++;
                j++;
                break;
            }
        }
    }
    cout << num.size() - ans << endl;
    return 0;
}


//IN THE NAME OF GOD
#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <fstream>
#include <utility>
#include <sstream>
#include <list>
#include <iomanip>
#include <functional>
#include <deque>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <complex>
#include <climits>
#include <cctype>
#include <cassert>
#include <bitset>
#include <limits>
#include <numeric>

using namespace std ;

#define timestamp(x) printf("Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define INF 0x3f3f3f3f
#define pii pair < int , int >
#define MP make_pair
#define MOD 1000000007
#define EPS 1e-9

bitset < 500000+100 > visit ;

int main ()
{
    //freopen ( "i.txt" , "r" , stdin ) ;
    int n , tmp ;
    vector < int > num ;
    cin >> n ;
    while ( n-- ){
        cin >> tmp ;
        num.push_back ( tmp ) ;
    }
    sort ( num.begin() , num.end() ) ;
    int l = num.size()-1 , ans = (int)(num.size()) ;
    for ( int i = num.size()-2 ; i >= 0 ; i-- ){
        if ( visit[i] ) continue ;
        while ( visit[l] ){
            l-- ;
        }
        if ( l == i ) continue ;
        if ( num[l] >= num[i]*2 ){
            visit[i] = visit[l] = 1 ;
            ans-- ;
            if ( abs ( l-i ) == 1 ){
                l = i - 1 ;
                i -= 2 ;
            }else{
                l-- ;
            }
        }
    }
    cout << ans << endl ;
    return 0 ;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>=2*a[j])
            {
                //g[i].push_back(j);
                g[j].push_back(i);
            }
        }

    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i)
        if (mt[i] == -1)
            kol++;
    cout<<kol<<endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> h;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    h.assign(n,0);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]*2<=a[j])
            {
                g[j].push_back(i);
            }
        }
    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i){
        if (mt[i] == -1)
        {
            kol++;
        }
    }
    cout<<kol;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> h;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    h.assign(n,0);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>=2*a[j])
            {
                g[i].push_back(j);
            }
        }
    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i){
        if (mt[i] != -1)
        {
            kol++;
        }
    }

    int res=0;
    res=(n-(kol*2))+kol;
    cout<<res<<endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> h;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    h.assign(n,0);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>=2*a[j])
            {
                g[i].push_back(j);
            }
        }
    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i){
        if (mt[i] != -1)
        {
            kol++;
        }
    }
    int res=0;
    if(n%2!=0)
    {
        while(1);
    }
    else
        cout<<n-kol;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> h;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    h.assign(n,0);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>=2*a[j])
            {
                g[i].push_back(j);
            }
        }
    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i){
        if (mt[i] != -1)
        {
            h[i]++;
            h[mt[i]]++;
        }
    }
    for (int i=0; i<n; ++i){
        if(h[i]==0) kol++;
    }
    kol+=(n-kol)/2;
    cout<<kol<<endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> h;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    h.assign(n,0);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>=2*a[j])
            {
                g[i].push_back(j);
            }
        }
    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i){
        if (mt[i] == -1)
        {
            kol++;
        }
    }
    int res=0;
    if(n==kol) cout<<kol<<endl;
    else
    {
    res=n-kol;
    cout<<res<<endl;}
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> h;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    h.assign(n,0);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>=2*a[j])
            {
                g[i].push_back(j);
            }
        }
    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i){
        if (mt[i] != -1)
        {
            kol++;
        }
    }
    int res=0;
    if(n==kol) while(1);
    else
    {
    res=n-kol;
    cout<<res<<endl;
    }
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
int n;

vector <int> a;

int main()
{
    cin>>n;
    a.resize(n);
    int ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    for(int i=0,j=(n+1)/2;i<n && j<n;j++)
        if(a[i]>=2*a[j]){ans++;i++;}
        cout<<n-ans<<endl;
}


#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
using namespace std;
int n;
vector<vector<int>> g;
vector <int> a;
vector <int> mt;
vector <int> used;
bool try_kuhn (int v) {
    if (used[v])  return false;
    used[v] = true;
    for (size_t i=0; i<g[v].size(); ++i) {
        int to = g[v][i];
        if (mt[to] == -1 || try_kuhn (mt[to])) {
            mt[to] = v;
            return true;
        }
    }
    return false;
}
int main()
{
    cin>>n;
    a.resize(n);
    used.assign(n,0);
    mt.assign(n,-1);
    g.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>2*a[j])
            {
                //g[i].push_back(j);
                g[j].push_back(i);
            }
        }

    }
    vector<char> used1 (n);
    for (int i=0; i<n; ++i)
        for (size_t j=0; j<g[i].size(); ++j)
            if (mt[g[i][j]] == -1) {
                mt[g[i][j]] = i;
                used1[i] = true;
                break;
            }
    for (int i=0; i<n; ++i) {
        if (used1[i])  continue;
        used.assign (n, false);
        try_kuhn (i);
    }
    int kol=0;
    for (int i=0; i<n; ++i)
        if (mt[i] == -1)
            kol++;
    cout<<kol<<endl;
}


#include<stdio.h>
#include<algorithm>

int n;

int data[500050];
int chk(int a){
	int i,j=a,chk2=0;
	for(i=0;i<a;i++){
		while(j<n){
			if(2*data[i]<=data[j]){
				j++;
				if(j==n) chk2=1;
				break;
			}
			j++;
		}
	}
	if(chk2==1) return n-a;
	else return 0;
}
int main()
{
	int i,s,h,m;
	int p,q,max=-1;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	std :: sort(data,data+n);
	s=0;h=n-1;
	while(1){
		m = (s + h)/2;
		p = chk(m);
		if(max<p) max = p;
		if(h<s ) break;
		if(p ==0) s = m+1;
		else if(p != 0) h = m-1;
		else break;
	}
	printf("%d",n-max);

	return 0;
}


#include<stdio.h>
#include<algorithm>

int n;

int data[500050];
int chk(int a){
	int i,j=a,chk2=0,cnt=0;
	for(i=0;i<a;i++){
		while(j<n){
			if(2*data[i]<=data[j]){
				j++;
				cnt++;
				if(j==n) chk2=1;
				break;
			}
			j++;
		}
	}
	if(chk2==1) return cnt;
	else return 0;
}
int main()
{
	int i,s,h,m;
	int p,q,max=-1;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	std :: sort(data,data+n);
	s=0;h=n-1;
	while(1){
		m = (s + h)/2;
		p = chk(m);
		if(max<p) max = p;
		if(h<s ) break;
		if(p ==0) s = m+1;
		else if(p != 0) h = m-1;
		else break;
	}
	printf("%d",n-max);

	return 0;
}


#include<stdio.h>
#include<algorithm>

int n;

int data[500050];
int chk(int a){
	int i,j=a,chk2=0;
	for(i=0;i<a;i++){
		while(j<n){
			if(2*data[i]<=data[j]){
				j++;
				if(j==n) chk2=1;
				break;
			}
			j++;
		}
	}
	if(chk2==1) return a;
	else return 0;
}
int main()
{
	int i,s,h,m;
	int p,q,max=-1;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	std :: sort(data,data+n);
	s=0;h=n-1;
	while(1){
		m = (s + h)/2;
		p = chk(m);
		if(max<p) max = p;
		if(h<s ) break;
		if(p ==0) s = m+1;
		else if(p != 0) h = m-1;
		else break;
	}
	printf("%d",n-max);

	return 0;
}


#include<iostream>
#include<set>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<fstream>
#include<list>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define reprng(i,a,b) for(int i = a; i <= (int)(b); ++i)
#define reprrng(i,n,a) for(int i = n;i >= (int)(a); --i)
#define For(it,c) for(auto  it=c.begin();it!=c.end();++it)
#define log2(n) (log10((long double)n) / log10((long double)2))
#define swap(a,b) a = a + b, b = a - b, a = a - b
#define mp make_pair
typedef long long ll;

int main()
{

	int n;
	cin >> n;
	vector<int>cang(n);
	rep(i, n)
		cin >> cang[i];
	sort(all(cang));
	if (n > 1)
	{
		int l, r;
		l = 0;
		r = n / 2;;
		int count = 0;
		while (l < n / 2 && r < n)
		{
			if (cang[l] * 2 <= cang[r])
			{
				r++;
				l++;
				count++;
			}
			else
				r++;
		}
		cout << n - count<<endl;;
	}
	else
		cout << n << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define maxn 500100
int s[maxn];
bool nos[maxn];
int dp[ maxn];
int main()
{
	int n,i,res;
	cin>>n;
	res=n;
	for (i=0;i<n;i++)
	{
		cin>>s[i];

	}
	sort(s,s+n);
	for(i=n-1;i>=0;i--)
	{
		for (int j=i-1;j>=0;j--){

			if( s[i]>=s[j]*2 && nos[j]==false ){

				nos[j]=true;
				res--;
				j=0;
				continue;

			}
		}
	}
	cout<<res;
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define maxn 500100
int s[maxn];

int main()
{
	int n,i,res,l=0,r;
	cin>>n;
	res=n;
	for (i=0;i<n;i++)
		cin>>s[i];
	sort(s,s+n);
	r=n/2;
	while(l<(n/2) && r<n){
		if (s[l]*2<=s[r]) l++,r++,res--;
		else r++;
	}
	cout<<res;
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 500002
int a[N];
void qsort(int first, int last)
{
    srand(123213);
    int i = first, j = last, x = a[(first+last)/2];
    int w;
     while (i<j) {
        while (a[i] < x) i++;
        while (a[j] > x) j--;

        if (i<=j) {
            w=a[i]; a[i]=a[j]; a[j]=w;
            i++; j--;
            }
     }
    if (i < last)
        qsort(i, last);
    if (first < j)
        qsort(first,j);
}
int main()
{
    int ans, i, n, j, pl, ps;
    scanf("%d", &n);
    for(i=0; i<n; i++)
        scanf("%d", &a[i]);

    qsort(0, n-1);

    ps = n/2-1;
    pl = n-1;
    ans = n;

    while(ps<pl)
    {
        if(ps<0)
            break;
        if(2*a[ps] <= a[pl])
            {
                ans--;
                pl--;
            }
        ps --;
    }
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>

using namespace std;

int input[500010];

int main()
{
	int i , j , n;
	while (scanf("%d" , &n) != EOF)
	{
		for (i = 0;i < n;i ++)
			scanf("%d" , &input[i]);
		sort(input , input + n);
		int pos1 = n / 2 - 1 , pos2 = n - 1;
		int ans = 0;
		// 直到处理完全
		while (pos1 >= 0 && pos2 >= n / 2)
		{
			if (input[pos2] >= input[pos1] * 2)
			{
				ans ++;
				pos1 --;
				pos2 --;
			}
			else
			{
				ans ++;
				pos1 --;
			}
		}
		if (pos1 >= 0)
			ans += pos1 + 1;
		if (pos2 >= n / 2)
			ans += (pos2 - n / 2 + 1);
		printf("%d\n" , ans);
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <numeric>
#include <queue>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <iomanip>
#include <set>
#include <queue>
#include <bitset>
#include <iomanip>
#include <map>
#include <string.h>
#include <stack>
#include <algorithm>

using namespace std;

struct node
{
	int left;
	int right;
	int minValue;
}tree[500010];

const int MAX = 1000000000;

int input[500010];
int cnt[100010];

void build(int pos , int left , int right)
{
	tree[pos].left = left;
	tree[pos].right = right;

	if (left == right)
	{
		if (cnt[left] == 0)
			tree[pos].minValue = MAX;
		else
			tree[pos].minValue = left;
	}
	else
	{
		int mid = (left + right) / 2;
		build(pos * 2 , left , mid);
		build(pos * 2 + 1 ,  mid + 1 , right);
		tree[pos].minValue = min(tree[pos * 2].minValue , tree[pos * 2 + 1].minValue);
	}
}

// 减少一个
void update(int pos , int position)
{
	// 更新最小值
	if (tree[pos].left == position && tree[pos].right == position)
	{
		cnt[position] --;
		if (cnt[position] == 0)
			tree[pos].minValue = MAX;
	}
	else
	{
		int mid = (tree[pos].left + tree[pos].right) / 2;
		if (position <= mid)
			update(pos * 2 , position);
		else
			update(pos * 2 + 1 , position);
		tree[pos].minValue = min(tree[pos * 2].minValue , tree[pos * 2 + 1].minValue);
	}
}

// 查找区间最小值
int query(int pos , int left , int right)
{
	// 如果找到了区间
	if (tree[pos].left == left && tree[pos].right == right)
		return tree[pos].minValue;
	else
	{
		int mid = (tree[pos].left + tree[pos].right) / 2;
		if (right <= mid)
			return query(pos * 2 , left , right);
		else if (left > mid)
			return query(pos * 2 + 1 , left , right);
		else
		{
			int ans1 = query(pos * 2 , left , mid);
			int ans2 = query(pos * 2 + 1 , mid + 1 , right);
			return min(ans1 , ans2);
		}
	}
}

int main()
{
	int i , j , n;
	while (scanf("%d" , &n) != EOF)
	{
		memset(cnt , 0 , sizeof(cnt));
		for (i = 0;i < n;i ++)
		{
			scanf("%d" , &input[i]);
			cnt[input[i]] ++;
		}
		build(1 , 1 , 100000);
		int ans = 0;
		for (i = 1;i <= 100000;i ++)
		{
			for (j = 0;j < cnt[i];j ++)
			{
				int cur = i , next;
				while (cur <= 100000)
				{
					if (cur > i)
						update(1 , cur);
					// 如果还有可能
					if (cur * 2 <= 100000)
					{
						next = query(1 , cur * 2 , 100000);
						if (next <= 100000)
							cur = next;
						else
							break;
					}
					else
						break;
				}
				ans ++;
			}
		}
		printf("%d\n" , ans);
	}
	return 0;
}


// WA (HARD)
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <iostream>
#include <iterator>

#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define FORN(i,b) FOR(i, 0, b)

#if defined(M_H_HOME) && (0)
#define DBG(x) cout << x
#else
#define DBG(x)
#endif

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	FORN(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int carrier = n - 1, passanger = n / 2 - 1, count = 0;
	while (carrier >= n / 2) {
		while (passanger >= 0 && a[passanger]*2 > a[carrier]) --passanger;
		if (passanger >= 0) {
			++count;
			--carrier;
			--passanger;
		} else {
			break;
		}
	}

	cout << n - count << endl;

/* ���������� ���������� - �������� ������������!
   �����-������ 4    8 4 2 2   (� ������ 8 - 4, ����� ����� 3 �������. ���� 8 - 2, 4 - 2 (����� 2)
	multiset<int> kangaroo;
	FORN(i, n) {
		int kanga;
		cin >> kanga;
		kangaroo.insert(kanga);
	}
	int count = 0;
	while (kangaroo.size() > 1) {
		// find carrier
		multiset<int>::iterator carrier = kangaroo.end();
		--carrier;
		// find passanger
		multiset<int>::iterator passanger = kangaroo.upper_bound(*carrier / 2);
		if (passanger == kangaroo.begin()) {
			break;
		} else {
			--passanger;
			kangaroo.erase(passanger);
			kangaroo.erase(carrier);
			++count;
		}
	}

	cout << count + kangaroo.size() << endl;
*/
	return 0;
}


#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <iostream>
#include <iterator>

#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define FORN(i,b) FOR(i, 0, b)

#if defined(M_H_HOME) && (0)
#define DBG(x) cout << x
#else
#define DBG(x)
#endif

using namespace std;

int main()
{
	int n;
	cin >> n;
	multiset<int> kangaroo;
	FORN(i, n) {
		int kanga;
		cin >> kanga;
		kangaroo.insert(kanga);
	}
	int count = 0;
	while (kangaroo.size() > 1) {
		// find carrier
		multiset<int>::iterator carrier = kangaroo.end();
		--carrier;
		// find passanger
		multiset<int>::iterator passanger = kangaroo.upper_bound(*carrier / 2);
		if (passanger == kangaroo.begin()) {
			break;
		} else {
			--passanger;
			kangaroo.erase(passanger);
			kangaroo.erase(carrier);
			++count;
		}
	}

	cout << count + kangaroo.size() << endl;

	return 0;
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int,int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a-1);(i)>=(b);--(i))
#define MP make_pair
#define MOD 1000000007
#define INF 1000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-8
#define X first
#define Y second

int n,a[1000000];

int main ()
{

    //ios_base::sync_with_stdio(0);
    //freopen("INPUT.txt","rt",stdin);freopen("OUTPUT.txt","wt",stdout);
    cin>>n;
    FOR(i,0,n)scanf("%d",&a[i]);
    sort(a,a+n);
    int ans=0,j=n/2-1;
    RFOR(i,n,n/2)
        if(a[i])
        {
            for(;j>=0 && a[j]*2>a[i];j--);
            if(j==-1)break;
            ans++;
            j--;
        }
    cout<<n-ans;
    return 0;
}


//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int,int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a-1);(i)>=(b);--(i))
#define MP make_pair
#define MOD 1000000007
#define INF 1000000000
#define PB push_back
#define x0 sdfhrthrth
#define x1 fdhttrlhn
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-8
#define X first
#define Y second

int n,a[1000000];

int main ()
{

    //ios_base::sync_with_stdio(0);
    //freopen("INPUT.txt","rt",stdin);freopen("OUTPUT.txt","wt",stdout);
    cin>>n;
    FOR(i,0,n)scanf("%d",&a[i]);
    sort(a,a+n);
    int ans=0;
    for(int i=0,j=1;i<n;i++)
    {
        for(;j<n && a[i]*2>a[j];j++);
        if(j==n)break;
        ans++;
    }
    cout<<n-ans;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>

using namespace std;

#ifdef __int64
typedef __int64 LL;
#else
typedef long long LL;
#endif

int s[500005];
int main()
{
    int n,i,l,t,ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
         cin>>s[i];
    }
    sort(s,s+n);
    t=n/2;
    ans=0;
    for(i=t,l=0;i<n&&l<t;i++)
    {
         if(2*s[l]<=s[i])
         {
              ans++;
              l++;
         }
    }
    cout<<n-ans*2+ans<<endl;
    return 0;
}


//In the name of God
//-----gmmj

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <map>
#include <sstream>
#include <ctime>

#define Time printf("\nTime : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC);
#define Rep(I,N) for(int I=0;I<N;++I)
#define For(J,R,K) for(int J=R;J<K;++J)
#define MP make_pair
#define ALL(X) (X).begin(),(X).end()
#define SF scanf
#define PF printf
#define pii pair<int,int>
#define Ff first
#define Ss second
#define Sort(v) sort(ALL(v))
#define Test freopen("a.in","r",stdin);
#define pb push_back
#define RLL(X) scanf("%I64d",&X);
#define RRLL(X,Y) scanf("%I64d %I64d",&X,&Y);
#define WLL(X) printf("%I64d",X);
#define WWLL(X,Y) printf("%I64d %I64d",X,Y);
#define Loop(N) RLL(N)Rep(i,N)
#define fill(a,n) memset(a,n,sizeof(a))
#define MAXN 100000+9
#define MAXM 5*100000+19

typedef long long ll;

using namespace std;

int flag[MAXN];
int arr [MAXM];
int main()
{
//	Test
	int n;cin>>n;
	int *p;
	p=arr;
	int t=n;
	while(t--)
	{
		cin>>*p;
		p++;
	}
	int *hi,*low;
	low=hi=arr;
	sort(arr,arr+n);
	arr[n]=-1;
	hi+=(n/2);
	int cnt=0;
	while(*hi!=-1)
	{
		if(*low*2<=*hi)
		{
			n--;
			low++;
			hi++;
		}
		else
		{
			hi++;
		}
	}
	cout<<n;
	return 0;
}


//In the name of God
//-----gmmj

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <map>
#include <sstream>
#include <ctime>

#define Time printf("\nTime : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC);
#define Rep(I,N) for(int I=0;I<N;++I)
#define For(J,R,K) for(int J=R;J<K;++J)
#define MP make_pair
#define ALL(X) (X).begin(),(X).end()
#define SF scanf
#define PF printf
#define pii pair<int,int>
#define Ff first
#define Ss second
#define Sort(v) sort(ALL(v))
#define Test freopen("a.in","r",stdin);
#define pb push_back
#define RLL(X) scanf("%I64d",&X);
#define RRLL(X,Y) scanf("%I64d %I64d",&X,&Y);
#define WLL(X) printf("%I64d",X);
#define WWLL(X,Y) printf("%I64d %I64d",X,Y);
#define Loop(N) RLL(N)Rep(i,N)
#define fill(a,n) memset(a,n,sizeof(a))
#define MAXN 100000+9
#define MAXM 5*100000+19

typedef long long ll;

using namespace std;

int flag[MAXN];
int arr [MAXM];
int main()
{
//	Test
	int n;cin>>n;
	int *p;
	p=arr;
	int t=n;
	while(t--)
	{
		cin>>*p;
		p++;
	}
	int *hi,*low;
	low=hi=arr;
	sort(arr,arr+n);
	arr[n]=-1;
	hi+=( (n+1)/2);
	int cnt=0;
	while(*hi!=-1)
	{
		if(*low*2<=*hi)
		{
			n--;
			low++;
			hi++;
		}
		else
		{
			hi++;
		}
	}
	cout<<n;
	return 0;
}


//In the name of God
//-----gmmj

#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <map>
#include <sstream>
#include <ctime>

#define Time printf("\nTime : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC);
#define Rep(I,N) for(int I=0;I<N;++I)
#define For(J,R,K) for(int J=R;J<K;++J)
#define MP make_pair
#define ALL(X) (X).begin(),(X).end()
#define SF scanf
#define PF printf
#define pii pair<int,int>
#define Ff first
#define Ss second
#define Sort(v) sort(ALL(v))
#define Test freopen("a.in","r",stdin);
#define pb push_back
#define RLL(X) scanf("%I64d",&X);
#define RRLL(X,Y) scanf("%I64d %I64d",&X,&Y);
#define WLL(X) printf("%I64d",X);
#define WWLL(X,Y) printf("%I64d %I64d",X,Y);
#define Loop(N) RLL(N)Rep(i,N)
#define fill(a,n) memset(a,n,sizeof(a))
#define MAXN 100000+9
#define MAXM 5*100000+19

typedef long long ll;

using namespace std;

int flag[MAXN];
int arr [MAXM];
int main()
{
//	Test
	int n;cin>>n;
	int *p;
	p=arr;
	int t=n;
	while(t--)
	{
		cin>>*p;
		flag[*p]++;
		p++;
	}
	int *hi,*low;
	low=hi=arr;
	sort(arr,arr+n);
	arr[n]=-1;
	while(t<n-1)
	{
		if(*hi>=2*(*low))
			break;
		hi++;
		t++;
	}
	int cnt=0;
	while(*hi!=-1)
	{
		if(*low*2<=*hi)
		{
			cnt++;
			low++;
			hi++;
		}
		else
		{
			hi++;
		}
	}
	cout<<n-cnt;
	return 0;
}


# include <iostream>
# include <cmath>
# include <algorithm>
using namespace std;
int arr[500009] , n;
void main()
{
	cin>>n;
	for (int i=0;i<n;i++)	cin>>arr[i];
	sort(arr,arr+n);
	int res = n , last = n-1;
	for (int i=n/2-1;i>=0;i--)
		if (2*arr[i] <= arr[last])
			{last--;	res--;}
	cout<<res<<endl;
}


# include <iostream>
# include <cmath>
# include <algorithm>
using namespace std;
int arr[500009] , n;
void main()
{
	cin>>n;
	for (int i=1;i<=n;i++)	cin>>arr[i];
	sort(arr+1,arr+n+1);
	int res = n , last = n;
	for (int i=n/2;i>=1;i--)
		if (2*arr[i] <= arr[last])
			{last--;	res--;}
	cout<<res<<endl;
}


# include <iostream>
# include <cmath>
# include <algorithm>
using namespace std;
int arr[500009] , n;
void main()
{
	cin>>n;
	for (int i=0;i<n;i++)	cin>>arr[i];
	sort(arr,arr+n);
	int res = n , last = n-1;
	for (int i=n/2;i>=0;i--)
		if (2*arr[i] <= arr[last])
			{last--;	res--;}
	cout<<res<<endl;
}


# include <iostream>
# include <cmath>
# include <algorithm>
using namespace std;
int arr[500009] , n;
void main()
{
	cin>>n;
	for (int i=0;i<n;i++)	cin>>arr[i];
	sort(arr+1,arr+n+1);
	int res = n , last = n-1;
	for (int i=n/2-1;i>=0;i--)
		if (2*arr[i] <= arr[last])
			{last--;	res--;}
	cout<<res<<endl;
}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <time.h>
#include <queue>
using namespace std;

typedef long long ll;
vector<int> v;

bool check(int m)
{
	if(m*2 > v.size())
		return false;
	int ptr2 = m;
	bool fl = 0;
	for(int i=0; i<m; ++i)
	{
		while(v[i] < v[ptr2]*2)
		{
			ptr2++;
			if(ptr2 == v.size())
			{
				fl = true;
				break;
			}
		}
		ptr2++;
		if(ptr2 == v.size() && i!=m-1)
		{
			fl = true;
			break;
		}
		if(fl)
			break;
	}
	if(fl)
		return false;
	else
		return true;
}
int main()
{
	int n;
	cin>>n;
	v.resize(n);
	map<int , int> ma;
	for(int i=0; i<n; ++i)
		cin>>v[i];
	sort(v.rbegin(), v.rend());

	int l =-1, r = n/2+1;
	while(r-l>1)
	{
		int m = (l+r)/2;
		if(check(m))
		{
			l = m;
		}
		else
			r= m;
	}
	int c = l;
	cout<<(n-c);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <time.h>
#include <queue>
using namespace std;

typedef long long ll;
vector<int> v;

bool check(int m)
{
	if(m*2 > v.size())
		return false;
	int ptr2 = m;
	bool fl = 0;
	for(int i=0; i<m; ++i)
	{
		while(v[i] < v[ptr2]*2)
		{
			ptr2++;
			if(ptr2 == v.size())
			{
				fl = true;
				break;
			}
		}
		ptr2++;
		if(ptr2 == v.size() && i!=m-1)
		{
			fl = true;
			break;
		}
		if(fl)
			break;
	}
	if(fl)
		return false;
	else
		return true;
}
int main()
{
	int n;
	cin>>n;
	v.resize(n);
	map<int , int> ma;
	for(int i=0; i<n; ++i)
		cin>>v[i];
	sort(v.rbegin(), v.rend());

	int l =-1, r = n+1;
	while(r-l>1)
	{
		int m = (l+r)/2;
		if(check(m))
		{
			l = m;
		}
		else
			r= m;
	}
	int c = l;
	cout<<(n-c);
	return 0;
}


#include<iostream>
#include<stdlib.h>

int l,r,a[500000],n,ans;

int compare ( const void * a, const void * b){
    return (*(int*)a - *(int*)b);
}

int main(){
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",&a[i]);
    qsort(a, n, sizeof(int), compare);

    ans = n;
    r=n/2;
    int mean = r;
    l=0;

    while(r<n && l<mean){
        if(a[l]*2 <= a[r]){
            l++;
            ans--;
        }else r++;
    }

    printf("%d",ans);
return 0;
}


#include<iostream>
#include<stdlib.h>

int l,r,a[500000],n,ans;

int compare ( const void * a, const void * b){
    return (*(int*)a - *(int*)b);
}

int main(){
    scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",&a[i]);
    qsort(a, n, sizeof(int), compare);

    ans = n;
    r=n/2;
    int mean = r;
    l=0;

    while(r<n && l<mean){
        if(a[l]*2 <= a[r]){
            l++;
            r++;
            ans--;
        }else r++;
    }

    printf("%d",ans);
return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int* s = new int[n];

    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }

    sort(s,s+n);

    bool b;
    int temp=0;
    for(int m=0;m<=n/2;m++)
    {
        b=1;
        for(int i=0;i<m;i++)
        {
            if(s[i]*2>s[n-m+i])
            {
                b=0;
                break;
            }
        }
        if(b)
            temp=m;
    }

    cout<<(n-temp);

    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int* s = new int[n];

    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }

    sort(s,s+n);

    bool b;
    int temp=0;
    int left=0;
    int right=n/2;
    int m;
    while(left<=right)
    {
        m=(left+right)/2;

        b=1;
        for(int i=0;i<m;i++)
        {
            if(s[i]*2>s[n-m+i])
            {
                b=0;
                break;
            }
        }
        if(b)
        {
            left = m+1;
        }
        else
        {
            right = m-1;
        }
    }

    cout<<(n-left+1);

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>

#define MAXLEN 500005

using namespace std;

int a[MAXLEN];

bool MyCompare(int a, int b) {
    return a < b;
} // a < b
int max(int a, int b) {
    return a > b ? a : b;
}
int min(int a, int b) {
    return a < b ? a : b;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a,b) * b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    sort(a, a + n, MyCompare);

    int p1 = n - 1, p2 = (n - 1) / 2;

    int ans = n;

    while (p2 >= 0)
    {
        if (a[p2] * 2 <= a[p1])
        {
            ans--;
            p2--;
            p1--;

        }
        else
            p2--;

    }

    printf("%d", ans);

    return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>

#define MAXLEN 500005

using namespace std;

vector<int> a;
int flag[MAXLEN];

bool MyCompare(int a, int b)
{
    return a > b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }

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

    memset(flag, 0, sizeof(flag));

    int p1 = 0, p2 = 1;

    int ans = n;
    int qwe = 0;

    while (p2 < n)
    {
        if (flag[p1] == 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[p1] = -1;
                flag[p2] = p1;

                ans--;

                p1++;
                p2++;

                continue;
            }
            else
                p2++;
        }

        if (flag[p1] > 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[ flag[p1] ] = -2;
                qwe++;

                flag[p1] = -1;
                flag[p2] = p1;

                p1++;
                p2++;

                continue;
            }
            else
                p2++;
        }
    }

    int tmp = 0, kol = 0;

    for (int i = 0; i < n; i++)
    {
        if (tmp != qwe)
        {
            if (flag[i] == -2)
                tmp++;

            continue;
        }

        if (flag[i] == 0)
            kol++;
    }

    ans -= (kol > qwe) ? qwe : kol;

    printf("%d", ans);

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>

#define MAXLEN 100005

using namespace std;

int a[MAXLEN];

bool MyCompare(int a, int b) {
    return a < b;
} // a < b
int max(int a, int b) {
    return a > b ? a : b;
}
int min(int a, int b) {
    return a < b ? a : b;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a,b) * b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    sort(a, a + n, MyCompare);

    int p1 = n - 1, p2 = (n - 1) / 2;

    int ans = n;

    while (p2 >= 0)
    {
        if (a[p2] * 2 <= a[p1])
        {
            ans--;
            p2--;
            p1--;

        }
        else
            p2--;

    }

    printf("%d", ans);

    return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>

#define MAXLEN 500005

using namespace std;

int max(int a, int b)
{
    return a > b ? a : b;
}

vector<int> a;
int flag[MAXLEN];

bool MyCompare(int a, int b)
{
    return a > b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }

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

    memset(flag, 0, sizeof(flag));

    int p1 = 0, p2 = 1;

    int ans = n;
    int qwe = 0;

    while (p2 < n)
    {
        if (flag[p1] == 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[p1] = -1;
                flag[p2] = p1;

                ans--;

                p1++;
                p2++;

                continue;
            }
            else
                p2++;
        }

        if (flag[p1] > 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[ flag[p1] ] = -2;
                qwe++;

                flag[p1] = -1;
                flag[p2] = p1;

                p1++;
                p2++;

                continue;
            }
            else
                p2++;
        }
    }

    int tmp = 0, kol = 0;

    for (int i = 0; i < n; i++)
    {
        if (tmp < qwe)
        {
            if (flag[i] == -2)
                tmp++;

            continue;
        }

        if (flag[i] == 0)
            kol++;
    }

    ans -= (kol > qwe) ? qwe : kol;

    printf("%d", max(ans, n / 2 + n % 2));

    return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>

#define MAXLEN 500005

using namespace std;

vector<int> a;
int flag[MAXLEN];

bool MyCompare(int a, int b)
{
    return a > b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }

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

    memset(flag, 0, sizeof(flag));

    int p1 = 0, p2 = 1;

    int ans = n;

    while (p2 != n)
    {
        if (flag[p1])
        {
            p1++;
            continue;
        }

        if (flag[p2])
        {
            p2++;
            continue;
        }

        if (flag[p1] == 0 && flag[p2] == 0)
        if (a[p1] >= a[p2] * 2)
        {
            flag[p1] = 2;
            flag[p2] = 1;

            p1++;
            p2++;

            ans--;

            continue;
        }
        else
            p2++;
    }

    printf("%d", ans);

    return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>

#define MAXLEN 500005

using namespace std;

vector<int> a;
int flag[MAXLEN];

bool MyCompare(int a, int b)
{
    return a > b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }

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

    memset(flag, 0, sizeof(flag));

    int p1 = 0, p2 = 1;

    int ans = n;

    while (p2 != n)
    {
        if (flag[p1])
        {
            p1++;
            continue;
        }

        if (flag[p2])
        {
            p2++;
            continue;
        }

        if (p1 >= p2)
            p2 = p1 + 1;

        if (flag[p1] == 0 && flag[p2] == 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[p1] = 2;
                flag[p2] = 1;

                p1++;
                p2++;

                ans--;

                continue;
            }
            else
                p2++;
        }

    }

    printf("%d", ans);

    return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>

#define MAXLEN 500005

using namespace std;

int a[MAXLEN];

bool MyCompare(int a, int b) {
    return a < b;
} // a < b
int max(int a, int b) {
    return a > b ? a : b;
}
int min(int a, int b) {
    return a < b ? a : b;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a,b) * b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);

    sort(a, a + n, MyCompare);

    int p1 = n - 1, p2 = (n - 1 - n % 2) / 2;

    int ans = n;

    while (p2 >= 0)
    {
        if (a[p2] * 2 <= a[p1])
        {
            ans--;
            p2--;
            p1--;

        }
        else
            p2--;

    }

    printf("%d", ans);

    return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>

#define MAXLEN 500005

using namespace std;

vector<int> a;
int flag[MAXLEN];

bool MyCompare(int a, int b)
{
    return a > b;
}

int main()
{
    int n;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }

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

    memset(flag, 0, sizeof(flag));

    int p1 = 0, p2 = 1;

    int ans = n;
    int qwe = 0;

    while (p2 < n)
    {
        if (flag[p1] == 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[p1] = -1;
                flag[p2] = p1;

                ans--;

                p1++;
                p2++;

                continue;
            }
            else
                p2++;
        }

        if (flag[p1] > 0)
        {
            if (a[p1] >= a[p2] * 2)
            {
                flag[ flag[p1] ] = -2;
                qwe++;

                flag[p1] = -1;
                flag[p2] = p1;

                p1++;
                p2++;

                continue;
            }
            else
                p2++;
        }
    }

    int tmp = 0, kol = 0;

    for (int i = 0; i < n; i++)
    {
        if (tmp != qwe)
        {
            if (flag[i] == -2)
                tmp++;

            continue;
        }

        if (flag[i] == 0)
            kol++;
    }

    ans -= (qwe - kol > 0) ? qwe - kol : 0;

    printf("%d", ans);

    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int a[500005];
int main()
{
	int i,n,l,r,mid,sum,num;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+1+n);
	a[n+1]=0x7fffffff;a[0]=-1;r=n+1;sum=0;
	for(i=0,num=a[n-i]/2;i*2+2<=n;i++,num=a[n-i]/2)
	{
		l=0;
		while (l+1<r)
		{
			mid=(l+r)>>1;
			if(a[mid]<=num)l=mid;
			else r=mid;
		}
		if(l)
		{
			r=l;a[r]=0x7fffffff;
			sum++;
		}
	}
	printf("%d",n-sum);
	return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int a[500005];
int main()
{
	int i,n,l,r,mid,sum,num;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	sort(a+1,a+1+n);
	a[n+1]=0x7fffffff;a[0]=-1;r=n/2+1;sum=0;
	for(i=0,num=a[n-i]/2;i*2+2<=n;i++,num=a[n-i]/2)
	{
		l=0;
		while (l+1<r)
		{
			mid=(l+r)>>1;
			if(a[mid]<=num)l=mid;
			else r=mid;
		}
		if(l)
		{
			r=l;a[r]=0x7fffffff;
			sum++;
		}
	}
	printf("%d",n-sum);
	return 0;
}


/* Author : Prateep  */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <iterator>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <cassert>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <ctime>

using namespace std;

#define LET(x,a)        __typeof(a) x(a)
#define IFOR(i,a,b)     for(LET(i,a);i!=(b);++i)
#define EACH(it,v)      IFOR(it,v.begin(),v.end())
#define FOR(i,a,b)      for(int i=(int)(a) ; i < (int)(b);i++)
#define REP(i,n)        FOR(i,0,n)
#define SZ              size()
#define PB              push_back
#define PF              push_front
#define V(x)            vector< x >
#define two(X)          (1<<(X))
#define twoL(X)         (((int64)(1))<<(X))
#define contain(S,X)    (((S)&two(X))!=0)
#define containL(S,X)   (((S)&twoL(X))!=0
#define swap(x,y)       x ^=y ^= x^=y
#define ALL(v)          (v).begin(),(v).end()

const double pi=acos(-1.0);
const double eps=1e-11;
const int INFINITE=0x3f3f3f3f;
template<class T> inline void checkmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
template<class T> inline T lowbit(T n){return (n^(n-1))&n;}
template<class T> inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}

typedef long long       ll;
typedef V(int)          VI;
typedef V(VI)           VII;
typedef V(string)       VS;
typedef long long       int64;
typedef long double     LD;
typedef pair<int,int>   PI;

//#define LocalHost
#pragma comment(linker, "/STACK:200000000")
const int MAXN = (int) (5 * 1e5+1);
int s[MAXN];
int main()
{
#ifdef LocalHost
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	int n; cin >> n;
	FOR(i,1,n+1) cin >> s[i];
	sort(s+1,s+n+1);
	int r = n, l = n >> 1, res = n;
	while(r > (n >> 1) && l > 0) {
		if(2*s[l] <= s[r]) {
			--r; --res;
		}
		--l;
	}
	cout << res << endl;
	return 0;
}


#include <iostream>
using namespace std;
int a[500000];
void qs(int q,int w){
  int e=q,r=w,t=a[q+(rand()%(w-q+1))],y;
  do{
  while(a[e]<t)e++;
  while(a[r]>t)r--;
  if(e<=r){
   y=a[e];a[e]=a[r];a[r]=y;
   e++;r--;}
  }while(e<=r);
  if(q<r)qs(q,r);
  if(e<w)qs(e,w);
}
int main(){
  int q,q1,w,e,r,t;
  cin>>q;t=q;
  for(w=0;w<q;w++)
   cin>>a[w];
  qs(0,q-1);
  q1=q/2;
  w=0;
  e=q1;
  while((w<q1)&&(e<q)){
   r=a[w]*2;
   while((e<q)&&(a[e]<r))
    e++;
   if(e<q){
    w++;e++;
    t--;}}
  cout<<t;
  return 0;}


#include <iostream>
using namespace std;
int a[500000];
void qs(int q,int w){
  int e=q,r=w,t=a[q+(rand()%(w-q+1))],y;
  do{
  while(a[e]<t)e++;
  while(a[r]>t)r--;
  if(e<=r){
   y=a[e];a[e]=a[r];a[r]=y;
   e++;r--;}
  }while(e<=r);
  if(q<r)qs(q,r);
  if(e<w)qs(e,w);
}
int main(){
  int q,q1,w,e,r,t;
  cin>>q;t=q;
  for(w=0;w<q;w++)
   cin>>a[w];
  qs(0,q-1);
  q1=q/2;
  w=0;
  e=q1;
  while((w<q1)&&(e<q)){
   r=a[w]*2;
   while((e<q)&&(a[e]<r))
    e++;
   if(e<q){
    w++;r++;
    t--;}}
  cout<<t;
  return 0;}


import math,sys

n=int(input());k=n

a=sorted([int(x) for x in sys.stdin.read().strip().split('\n')])

p1=math.floor((n-1)/2);p2=n-1

while p1>=0:

    if 2*a[p1]<=a[p2]:

        k-=1;a[p2]=0;p2-=1

    p1-=1

k=max(math.ceil(n/2),k)

sys.stdout.write(str(k))

# Made By Mostafa_Khaled


n=gets.to_i
a=[]
n.times{a<<gets.to_i}
a.sort!.reverse!
i=c=0
j=n/2
while j<n
  (c+=1;i+=1)if a[i]/2>=a[j]
  j+=1
end
p n-c


n=gets.to_i
a=[]
n.times{a<<gets.to_i}
a.sort!.reverse!
i=j=c=0
while j<n
  (c+=1;i+=1)if a[i]/2>=a[j]
  j+=1
end
p n-c


n=gets.to_i
a=[]
n.times{a<<gets.to_i}
a.sort!.reverse!
i=c=0
j=(n+1)/2
while j<n
  (c+=1;i+=1)if a[i]/2>=a[j]
  j+=1
end
p n-c


#import sys
#sys.stdin = open('in')

n = int(raw_input())
sz = []
for i in range(n):
    sz.append(int(raw_input()))
s = sorted(sz)
l = n/2
r = n
def check(m):
    l = 0
    r = n/2
    while l < m and r < n:
        if s[l]*2 <= s[r]:
            l += 1
        r += 1
    return l == m

while (r - l) > 1 :
    m = (r + l) / 2
    if check(m):
        l = m
    else:
        r = m - 1
if check(r):
    l = r
print l + 1


#import sys
#sys.stdin = open('in')

n = int(raw_input())
n2 = n/2
sz = []
for i in range(n):
    sz.append(int(raw_input()))
s = sorted(sz)
l = 0
r = n2
while l < n2 and r < n:
    if s2[l] <= s[r]:
        l += 1
    r += 1
print n - l


#import sys
#sys.stdin = open('in')

n = int(raw_input())
sz = []
for i in range(n):
    sz.append(int(raw_input()))
s = sorted(sz)
l = 0
r = n/2
def check(mi):
    li = 0
    ri = n/2
    while li < mi and ri < n:
        if s[li]*2 <= s[ri]:
            li += 1
        ri += 1
    return li == mi

while (r - l) > 1 :
    m = (r + l) / 2
    if check(m):
        l = m
    else:
        r = m - 1
if check(r):
    l = r
print n - l


#import sys
#sys.stdin = open('in')

n = int(raw_input())
n2 = n/2
sz = [0]*n
for i in range(n):
    sz[i] =int(raw_input())
s = sorted(sz)
s2 = map(lambda x: x*2, s)
l = 0
r = n2
def check(mi):
    li = 0
    ri = n2
    while li < mi and ri < n:
        if s2[li] <= s[ri]:
            li += 1
        ri += 1
    return li == mi

while (r - l) > 1 :
    m = (r + l) / 2
    if check(m):
        l = m
    else:
        r = m - 1
if check(r):
    l = r
print n - l


#import sys
#sys.stdin = open('in')

n = int(raw_input())
n2 = n/2
sz = [0]*n
for i in range(n):
    sz[i] =int(raw_input())
s = sorted(sz)
s2 = map(lambda x: x*2, s)
l = 0
r = n2
while l < n2 and r < n:
    if s2[l] <= s[r]:
        l += 1
    r += 1
print n - l


#import sys
#sys.stdin = open('in')

n = int(raw_input())
n2 = n/2
sz = []
for i in range(n):
    sz.append(int(raw_input()))
s = sorted(sz)
l = 0
r = n2
while l < n2 and r < n:
    if s[l]*2 <= s[r]:
        l += 1
    r += 1
print n - l


#import sys
#sys.stdin = open('in')

n = int(raw_input())
sz = [0]*n
for i in range(n):
    sz[i] =int(raw_input())
s = sorted(sz)
l = 0
r = n/2
def check(mi):
    li = 0
    ri = n/2
    while li < mi and ri < n:
        if s[li]*2 <= s[ri]:
            li += 1
        ri += 1
    return li == mi

while (r - l) > 1 :
    m = (r + l) / 2
    if check(m):
        l = m
    else:
        r = m - 1
if check(r):
    l = r
print n - l