#include <bits/stdc++.h>
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main(void) {
  int n;
  scanf("%d", &n);
  int arr[n], i;
  for (i = 0; i < n; i++) scanf("%d", &arr[i]);
  int a1[n], a2[n], j = 0, k = 0;
  qsort(arr, n, sizeof(int), compare);
  for (i = 0; i < n; i++) {
    if (arr[i] == arr[i + 1]) {
      a1[j] = arr[i];
      a2[k] = arr[i];
      j++;
      k++;
      while (arr[i] == arr[i + 1]) i++;
    } else {
      a1[j] = arr[i];
      j++;
    }
  }
  if (a1[j - 1] == a2[k - 1]) k--;
  printf("%d\n", j + k);
  i = 0;
  while (i < k) {
    printf("%d ", a2[i]);
    i++;
  }
  while (j--) {
    printf("%d ", a1[j]);
  }
  return 0;
}
