#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
int a;
cin >> a;
int b[a];
for(int i = 0; i < a; i++){
cin >> b[i];
}
//存入資料
int m = -1;
int n = 101;
for(int i = 0; i < a; i++){
if(b[i] < 60){
if(b[i] > m){
m = b[i];
}
}else if(b[i] >= 60){
if(b[i] < n){
n = b[i];
}
}
}
//找出目標成績
for(int p = 1; p < a; p++){
for(int k = p; k > 0; k--){
if(b[k] < b[k-1]){
int z;
z = b[k-1];
b[k-1] = b[k];
b[k] = z;
}else{
break;
}
}
}
//由小而大排列成績
for(int i = 0; i < a; i++){
cout << b[i] << " ";
}
cout << endl;
//由小而大輸出成績
if(m == -1 && n != 101){
cout << "best case" << endl;
cout << n << endl;
}
else if(m != -1 && n == 101){
cout << m << endl;
cout << "worst case" << endl;
}
else{
cout << m << endl;
cout << n << endl;
}
//輸出目標成績
return 0;
}