#include <stdio.h>

FILE *f;
long n;

long a[50001];

long tmp;

void unheap(long i)
{
	if (i>1)
	{
		tmp = a[i/2];
		a[i/2] = a[i];
		a[i] = tmp;
		unheap(i/2);
	}
}

int main()
{
	long i;//,j;

	f = fopen("heapsort.in","rt");
	fscanf(f, "%ld", &n);
	fclose(f);

	a[1] = 1;
	for (i=2; i<=n; i++)
	{
		unheap(i-1);
		a[1] = i;
		a[i] = 1;
		//for (j=1; j<=i; i++)
		//	fprintf(f, "%ld ", a[j]);
	}


	f = fopen("heapsort.out","wt");
	for (i=1; i<=n; i++)
		fprintf(f, "%ld ", a[i]);

	fclose(f);

	return 0;
}