#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000
int main() {
    int n;
    int arr[MAX];
    while (cin >>n) {
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        sort(arr,arr+n);
        cout<<arr[n-1]<<endl;
        if(n==1) cout<<-1;
        else{
            for(int i=0;i<n-1;i++){
                cout<<arr[i]<<" ";
            }
        }
    }
    return 0;
}