#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int t, n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int p = v[n - 1], q = p;
  list<int> l;
  l.push_back(p);
  for (int i = n - 2; i >= 0; i--) {
    if (v[i] < p) {
      l.push_front(v[i]);
      p = v[i];
    } else if (v[i] < q) {
      l.push_back(v[i]);
      q = v[i];
    }
  }
  cout << l.size() << '\n';
  for (list<int>::iterator it = l.begin(); it != l.end(); ++it)
    cout << *it << " ";
  cout << '\n';
  return 0;
}
