#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int> a, b;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (a.find(x) == a.end()) {
      a.insert(x);
    } else if (b.find(x) == b.end()) {
      b.insert(x);
    }
  }
  if (!b.empty()) {
    if ((*a.rbegin()) == (*b.rbegin())) {
      b.erase((--b.end()));
    }
  }
  cout << (a.size() + b.size()) << endl;
  for (int i : a) {
    cout << i << " ";
  }
  for (auto it = b.rbegin(); it != b.rend(); it++) {
    cout << (*it) << " ";
  }
  cout << endl;
  return 0;
}
