#include <bits/stdc++.h>
using namespace std;
int cnt[5500];
int main() {
  int n;
  scanf("%d", &n);
  int inp[n + 1];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) {
    scanf("%d", &inp[i]);
    cnt[inp[i]] += 1;
  }
  vector<int> v;
  int l = 0;
  for (int i = 0; i <= 5000; i++) {
    if (cnt[i] > 0) {
      v.push_back(i);
      cnt[i] -= 1;
      l = max(l, i);
    }
  }
  for (int i = l - 1; i >= 0; i--) {
    if (cnt[i] > 0) {
      v.push_back(i);
    }
  }
  n = v.size();
  printf("%d\n", n);
  for (int i = 0; i < n; i++) {
    printf("%d", v[i]);
    if (i != n - 1) printf(" ");
  }
  return 0;
}
