#include <stdio.h>

void exch(int *a, int *b)
{
	int c = *b;
	*b = *a;
	*a = c;
}

int main(void)
{
	FILE *f;
	int mas[50010];
	int n, i, j;

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

	for (i = 1; i <= n; i++)
		mas[i] = i;

	for (j = 1; j < n; j++) {
		for (i = j; i > 1; i/= 2) 
			exch(&mas[i], &mas[i/2]);
		exch(&mas[1], &mas[j+1]);
	}

	f = fopen("heapsort.out", "w");
	fprintf(f, "%d", mas[1]);
	for (i = 2; i <= n; i++)
		fprintf(f, " %d", mas[i]);
	fclose(f);

	return 0;
}
