#include <bits/stdc++.h>
using namespace std;
const int CMax = 5002;
const int CMax2 = 100002;
int m, B[CMax], A[CMax2], ats = 0, sk, pr;
int main() {
  scanf("%d", &m);
  for (int i = 0; i < CMax; i++) {
    B[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &sk);
    B[sk]++;
  }
  for (int i = 0; i < CMax; i++) {
    if (B[i] > 0) {
      B[i]--;
      A[ats] = i;
      ats++;
      pr = i;
    }
  }
  for (int i = pr - 1; i >= 0; i--) {
    if (B[i] > 0) {
      B[i]--;
      A[ats] = i;
      ats++;
    }
  }
  printf("%d\n", ats);
  if (ats > 0) {
    for (int i = 0; i < ats - 1; i++) {
      printf("%d ", A[i]);
    }
    printf("%d\n", A[ats - 1]);
  }
}
