#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;
cin>>k;
int a[k],highestlow=-1,lowesthigh=59;
for(int i=0; i<k; i++)
{
cin>>a[i];
}
sort(a,a+k);
for(int i=0; i<k; i++)
{
if(a[i]>highestlow && a[i]<60) highestlow=a[i];
if(a[i]>59)
{
lowesthigh=a[i];
break;//因已排列好所以在找到lowesthigh直接結束迴圈
}
}
for(int i=0; i<k; i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
if(highestlow==-1) cout<<"best case"<<endl;
else cout<<highestlow<<endl;
if(lowesthigh==59) cout<<"worst case"<<endl;
else cout<<lowesthigh<<endl;
}