#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n){ int temp; vector<int>v; while(n--){ cin>>temp;v.push_back(temp); } cout<<*max_element(v.begin(),v.end())<<endl; v.erase(max_element(v.begin(),v.end())); sort(v.begin(),v.end()); for(auto a :v) cout<<a<<" "; if(v.size() == 0)cout<<-1<<endl; else cout<<endl; } } // 64 位输出请用 printf("%lld")