#include <bits/stdc++.h>
using namespace std;
int a[5001];
int main() {
  int i, j, n, c = 0;
  cin >> n;
  vector<int> v;
  for (i = 0; i < n; i++) {
    cin >> j;
    a[j]++;
  }
  for (i = 1; i <= 5000; i++)
    if (a[i]) {
      v.push_back(i);
      a[i]--;
      c = i;
    }
  for (i = c - 1; i; i--)
    if (a[i]) {
      v.push_back(i);
    }
  cout << v.size() << "\n";
  for (i = 0; i < (int)v.size(); i++) cout << v[i] << " ";
  return 0;
}
