#include<bits/stdc++.h>
using namespace std;
const int N = 1000+10;
int f[N];
int n;
int maxi = 0;
int main(){
cin>>n;
for(int i = 1;i<=n;i++){
cin>>f[i];
maxi = max(maxi,f[i]);
}
cout<<maxi<<"\n";
if(n==1){
cout<<-1;
return 0;
}
sort(f+1,f+1+n);
for(int i = 1;i<=n-1;i++){
cout<<f[i]<<" ";
}
return 0;
}