#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int a[maxn];
int f[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    f[t]++;
  }
  int num = 0;
  int Max = 0;
  for (int i = 0; i <= 5000; i++) {
    if (f[i]) {
      f[i]--;
      Max = i;
      a[num++] = i;
    }
  }
  for (int i = Max - 1; i >= 1; i--) {
    if (f[i]) {
      f[i]--;
      a[num++] = i;
    }
  }
  printf("%d\n", num);
  for (int i = 0; i < num - 1; i++) {
    printf("%d ", a[i]);
  }
  printf("%d\n", a[num - 1]);
}
