#include<iostream>
#include <stdlib.h>
using namespace std;
int main(){
int n,w=0,j=0;//worse best,best worse
cin>>n;
int b[n]={0},c[n]={0},a[n]={0};
for(int i = 0;i<n;i++){
cin>>b[i];
}
for(int i = 1;i<n;i++){
for(int j = 0; j < n-i ; j++){
if(b[j]>b[j+1]){
w = b[j];
b[j] = b[j+1];
b[j+1] = w;
}
}
}
for(int i =0;i<n-1;i++){
cout<<b[i]<<" ";
}
cout<<b[n-1];
cout<<endl;
for(int i=0;i<n;i++){
if(b[i]<60){
c[i]=b[i];
j++;
}
else if(b[i]>=60){
a[i-j]=b[i];
}
}
if(c[j-1]==0){
cout<<"best case"<<endl;
}else if(c[j-1]<60){
cout<<c[j-1]<<endl;
}
if(a[0]==0){
cout<<"worst case"<<endl;
}else if(a[0]>=60){
cout<<a[0]<<endl;
}
return 0;
}