#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(begin(v), end(v));
  int max = v[n - 1];
  set<int> left, right;
  right.insert(max);
  for (int i = n - 2; i >= 0; i--) {
    if (v[i] != max) {
      if (v[i + 1] == v[i]) {
        left.insert(v[i]);
      } else
        right.insert(v[i]);
    }
  }
  cout << left.size() + right.size() << endl;
  for (auto& item : left) {
    cout << item << " ";
  }
  for (auto item = prev(right.end()); item != prev(right.begin()); item--) {
    cout << *item << " ";
  }
  return 0;
}
