#include <bits/stdc++.h>
using namespace std;
void _main();
int main() {
  _main();
  return 0;
}
long a[100000];
void _main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(&a[0], &a[n]);
  list<long> re1;
  list<long> re2;
  long lastone = -1;
  bool pushed = false;
  long num = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == lastone) {
      if (!pushed) {
        re1.push_front(lastone);
        pushed = true;
      }
    } else {
      re2.push_back(a[i]);
      pushed = false;
      lastone = a[i];
    }
  }
  num = re1.size() + re2.size();
  if (!re1.empty() && !re2.empty() && re1.front() == re2.back()) {
    num--;
    re2.pop_back();
  }
  cout << num << endl;
  for (auto it = re2.begin(); it != re2.end(); it++) cout << *it << " ";
  for (auto it = re1.begin(); it != re1.end(); it++) cout << *it << " ";
}
