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