'BEGIN''ARRAY' A[1:100];
'INTEGER' I,N,INDEV;

'PROCEDURE' QSORT(ARR,LOW,HIGH); 'VALUE' LOW,HIGH;
'ARRAY' ARR; 'INTEGER'LOW,HIGH;
'IF' LOW<HIGH 'THEN'
'BEGIN''INTEGER' TOP,BOTTOM; 'REAL' X;
BOTTOM:=LOW-1; TOP:=HIGH;
LOOP1: BOTTOM:=BOTTOM+1;
	'IF' ARR[BOTTOM]<ARR[HIGH] 'THEN''GOTO' LOOP1;
LOOP2: TOP:=TOP-1;
	'IF' ARR[TOP]>=ARR[HIGH] 'AND' TOP>BOTTOM
	'THEN''GOTO' LOOP2;
'IF' TOP>BOTTOM 'THEN'
	'BEGIN' X:=ARR[TOP]; ARR[TOP]:=ARR[BOTTOM];
	ARR[BOTTOM]:=X; 'GOTO' LOOP1;
	'END';
X:=ARR[HIGH]; ARR[HIGH]:=ARR[BOTTOM]; ARR[BOTTOM]:=X;
QSORT(ARR,LOW,BOTTOM-1); QSORT(ARR,BOTTOM+1,HIGH);
'END' QSORT;

START: IOC(4); INDEV:=INPUT; 'IF' INDEV<0 'THEN''GOTO' START;
N:=READ(INDEV); 'FOR' I:=1 'STEP' 1 'UNTIL' N 'DO'
		A[I]:=READ(INDEV);
QSORT(A,1,N);
'FOR' I:=1 'STEP' 1 'UNTIL' N 'DO'
	'BEGIN' RWRITE(1,A[I],8,0);
	'IF' I=I%5*5 'THEN' SKIP(1);
	'END';
CLOSE(INDEV); 'GOTO' START;
'END''FINISH'
