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