#include #include using namespace std; int main() { int count, tmp; vector packs; while(1) { cin >> count; if(count == 0) break; packs.clear(); for(int i = 0; i < count; ++i) { cin >> tmp; packs.push_back(tmp); } sort(packs.begin(), packs.end()); bool je = true; int i = 0, j = packs.size() - 1; for(; i < j; ++i, --j) { if(je) { if(i > 0) cout << " "; cout << packs[i] << "-A"; cout << " " << packs[j] << "-B"; } else { cout << " " << packs[j] << "-A"; cout << " " << packs[i] << "-B"; } je = !je; } if(i == j) { if(je) { if(i > 0) cout << " "; cout << packs[i] << "-A"; } else { cout << " " << packs[j] << "-A"; } } cout << endl; } return 0; }