#include <bits/stdc++.h>
using namespace std;
int main() {
  int m;
  cin >> m;
  int b[5001] = {0}, x, a[m], k = 0, h;
  for (int i = 0; i < m; i++) {
    cin >> x;
    b[x]++;
  }
  for (int i = 1; i < 5001; i++) {
    if (b[i]) {
      a[k] = i;
      k++;
      b[i]--;
      h = i;
    }
  }
  for (int i = h - 1; i > 0; i--) {
    if (b[i]) {
      a[k] = i;
      k++;
      b[i]--;
    }
  }
  cout << k << endl;
  for (int i = 0; i < k; i++) {
    cout << a[i] << " ";
  }
  return 0;
}
