#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, p = 0, q = 0, i, k;
  cin >> n;
  vector<long long int> a(n), b, c;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  k = a[n - 1];
  for (i = 0; i < n; i++) {
    if (a[i] > p) {
      p = a[i];
      b.push_back(p);
      a[i] = 0;
    }
  }
  for (i = 0; i < n; i++)
    if (a[i] == k) a[i] = 0;
  for (i = 0; i < n; i++) {
    if (a[i] > q) {
      q = a[i];
      c.push_back(q);
      a[i] = 0;
    }
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  cout << b.size() + c.size() << endl;
  for (i = 0; i < b.size(); i++) cout << b[i] << " ";
  for (i = 0; i < c.size(); i++) cout << c[i] << " ";
  return 0;
}
