#include <stdio.h>

int* function(int n, int a[])
{
	int i, j;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n - i - 1; j++)
		{
			if (a[j] > a[j + 1])
			{
				int t = a[j];
				a[j] = a[j + 1];
				a[j + 1] = t;
			}
		}
	}
	return a;
}

int main()
{
	int n;
	int a[1001], * b;
	printf("Please input N:\n");
	scanf_s("%d", &n);
	printf("Please input %d numbers:\n", n);
	int i;
	for (i = 0; i < n; i++)
	{
		scanf_s("%d", &a[i]);
	}
	b = function(n, a);
	printf("from largest to smallest: ");
	for (i = n - 1; i >= 0; i--)
	{
		printf("%d ", b[i]);
	}
	printf("\nfrom smallest to largest: ");
	for (i = 0; i < n; i++)
	{
		printf("%d ", b[i]);
	}
	return 0;
}