#include <bits/stdc++.h>
int main() {
  int n;
  int a[5001] = {0};
  scanf("%d", &n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    int aa;
    scanf("%d", &aa);
    if (mx < aa) mx = aa;
    a[aa]++;
  }
  int r = 0;
  int max = 0;
  int ab[10001] = {0};
  for (int i = 0; i <= mx; i++) {
    if (a[i]) {
      a[i]--;
      max = i;
      ab[r] = i;
      r++;
    }
  }
  for (int i = max - 1; i > 0; i--) {
    if (a[i]) {
      a[i]--;
      ab[r] = i;
      r++;
    }
  }
  printf("%d\n", r);
  for (int i = 0; i < r - 1; i++) {
    printf("%d ", ab[i]);
  }
  printf("%d\n", ab[r - 1]);
  return 0;
}
