#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int maxn=1000;
int main(){
int n;
while(scanf("%d",&n)!=EOF){
int arr[maxn];
if(n==1){
scanf("%d",&arr[0]);
printf("%d\n",arr[0]);
printf("-1");
break;
}
else{
for(int i=0;i<n;++i){
scanf("%d",&arr[i]);
}
sort(arr,arr+n);
for(int i=0;i<n-1;++i){
if(i==0){
printf("%d\n",arr[n-1]);
printf("%d",arr[0]);
}
else{
printf(" %d",arr[i]);
}
}
}
}
return 0;
}