#include<iostream>
#include<cstdio>
#include<algorithm>
#include <vector>
using namespace std;
bool compare(int lhs,int rhs){
    return lhs>rhs;
}
int main(){
    int N,m,l;
    scanf("%d",&N);
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        scanf("%d",&vec[i]);
    }
    if(N==1){
    	printf("%d\n",vec[0]);
    	printf("-1");
	}
    else{
	   sort(vec.begin(),vec.end(),compare);
       vector<int>::iterator it;
       it=vec.begin();
       printf("%d\n",*it);
       for(it=vec.end()-1;it!=vec.begin();it--){
           printf("%d ",*it);
       }
   }
   return 0;
}