#include <stdio.h>
void Ascending(int a[], int b) {
    while (b--) {
        for (int j = 0; j < b; j++) {
            if (a[j] > a[j + 1]) {
                int temp = a[j + 1];
                a[j + 1] = a[j];
                a[j] = temp;
            }
        }
    }
}
int main() {
    int n;
    scanf("%d", &n);
    int m = n;
    int Arr[n];
    int number = 0;
    while (n--) {
        scanf("%d", &Arr[number++]);
    }
    Ascending(Arr, m);
    printf("%d\n", Arr[m - 1]);
    if (m - 1 == 0)
        printf("-1\n");
    else
    {
        for (int i = 0; i < m - 1; i++)
        {
            printf("%d ", Arr[i]);
        }
        printf("\n");
    }
    return 0;
}