#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<algorithm>
#define MAX 1000000
using namespace std;
struct POINT
{
int x;
int y;
};
int N, S[MAX];
void print_array()
{
for(int i=0; i<N; i++) printf("%d ", S[i]);
printf("\n");
}
void swap(int a, int b)
{
int t = S[a];
S[a] = S[b];
S[b] = t;
}
bool compare(POINT a, POINT b)
{
if(a.x == b.x) return a.y < b.y;
else return a.x < b.x; // x멤버 기준으로 오름차순
}
void selection_sort(void)
{
for(int i=0; i<N-1; i++)
{
for(int j=i+1; j<N; j++)
{
if(S[i] > S[j]) swap(i, j);
}
}
}
void quick_sort(int s, int e)
{
if(s<e)
{
int p = s, l = s+1, r = e;
while(l<=r)
{
while(l<=e and S[l]<=S[p]) l++;
while(r>=s+1 and S[r]>=S[p]) r--;
if(l<r) swap(l, r);
}
swap(p, r);
quick_sort(s, r-1);
quick_sort(r+1, e);
}
}
int main()
{
srand(time(NULL));
scanf("%d", &N);
for(int i=0; i<N; i++) S[i] = rand();
// print_array();
int start = clock();
// selection_sort();
// sort(S, S+N);
quick_sort(0, N-1);
printf("result=%.3lf(sec)\n", (double)(clock()-start)/CLOCKS_PER_SEC);
// print_array();
}