#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[100001], d[100001], b[5001], i, n, x;
  cin >> n;
  for (i = 1; i <= 5000; i++) b[i] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    b[a[i]]++;
  }
  int l = 0;
  for (i = 1; i <= 5000; i++) {
    if (b[i] > 0) {
      l++;
      d[l] = i;
      x = i;
    }
    b[i]--;
  }
  for (i = 5000; i >= 1; i--)
    if (b[i] > 0 & i != x) {
      l++;
      d[l] = i;
    }
  cout << l << "\n";
  for (i = 1; i <= l; i++) cout << d[i] << " ";
  return 0;
}
