#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
inline long long read() {
  char tempt = getchar();
  long long x = 0, f = 0;
  while (tempt < '0' || tempt > '9') f |= tempt == '-', tempt = getchar();
  while (tempt >= '0' && tempt <= '9')
    x = x * 10 + tempt - '0', tempt = getchar();
  return f ? -x : x;
}
long long qmi(long long m, long long k, long long p) {
  long long res = 1 % p, t = m;
  while (k) {
    if (k & 1) res = res * t % p;
    t = t * t % p;
    k >>= 1;
  }
  return res;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long N = 5000 + 10;
long long st[N];
signed main() {
  long long n;
  cin >> n;
  for (register long long i = 1; i <= n; i++) {
    long long t;
    cin >> t;
    st[t]++;
  }
  vector<long long> vec;
  for (long long i = 1; i <= 5000; i++) {
    if (st[i]) {
      vec.push_back(i);
      st[i]--;
    }
  }
  st[vec.back()] = 0;
  for (long long i = 5000; i >= 1; i--) {
    if (st[i]) vec.push_back(i), st[i]--;
  }
  long long len = vec.size();
  cout << len << endl;
  for (long long i = 0; i < len; i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
