//土尔逊Torson 编写于2023/4/11
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <stdlib.h>
using namespace std;
bool comp028(int left, int right) {
if (left < right) {
return true;
}
else {
return false;
}
}
int main() {
int n;
int arr[1000] = { -1 };
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; ++i) {
scanf("%d", &arr[i]);
}
sort(arr, arr + n, comp028);
printf("%d\n", arr[n - 1]);
if (1 == n) {
printf("-1");
}
else {
for (int j = 0; j < n - 1; ++j) {
printf("%d ", arr[j]);
}
}
printf("\n");
}
system("pause");
return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")