#include<fstream.h>

int main()
{
	ofstream out("heapsort.out");
	ifstream in("heapsort.in");

	unsigned int n;
	in>>n;

	unsigned int ar[50001]={0};

	for( int i=0; i<n; i++ )
	{ ar[i]=i+1; }

	int temp;
	temp=ar[0];
	ar[0]=ar[n-1];
	ar[n-1]=temp;


	while( true )
	{
		bool c = false;

		for( int i=0; i<n/2; i++ )
		{
			if( ar[i]<ar[i*2+1]  || ar[i]<ar[i*2+2])
			{
				int max=ar[i*2+1]<ar[i*2+2]?i*2+1:i*2+2;
				if( ar[i]>ar[max] )
				{ max=ar[i*2+1]>ar[i*2+2]?i*2+1:i*2+2; }
				
				int temp;
				temp=ar[i];
				ar[i]=ar[max];
				ar[max]=temp;

				c = true;
			}
		}

		if ( !c )
		{
			break;
		}
	}

	for( i=0; i<n; i++ )
	{
		out<<ar[i]<<" ";
	}

	return 0;
}