#include <bits/stdc++.h>
using namespace std;
long long v[6000];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long val;
    cin >> val;
    v[val]++;
  }
  long long last = -1;
  queue<long long> q;
  queue<long long> st;
  for (int i = 6000; i >= 0; i--) {
    if (v[i] > 0) {
      v[i]--;
      q.push(i);
      if (last == -1) last = i;
    }
  }
  for (int i = 0; i < 6000; i++) {
    if (v[i] > 0 && i < last) {
      v[i]--;
      st.push(i);
    }
  }
  cout << st.size() + q.size() << endl;
  while (!st.empty()) {
    cout << st.front() << " ";
    st.pop();
  }
  while (!q.empty()) {
    cout << q.front() << " ";
    q.pop();
  }
  cout << endl;
  return 0;
}
