#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, N;
cin >> n;
vector<int>g1, g2, all;
for(int i=0; i<n;i++) {
cin >> N;
all.push_back(N);
if (N>=0&&N<60) g1.push_back(N);
else if (N>=60) g2.push_back(N);
}
sort(all.begin(), all.end());
sort(g1.begin(), g1.end());
sort(g2.begin(), g2.end());
for(int i=0;i<n;i++){
if(i>0) {
cout << " ";
}
cout << all[i];
}
cout << endl;
if(g1.empty()) {
cout << "best case" << endl;
}
else {
cout << g1.back() << endl;
}
if(g2.empty()) {
cout << endl << "worst case" ;
}
else {
cout << g2[0] << endl;
}
}