#include <bits/stdc++.h>
using namespace std;
deque<int> d;
int n, a[200000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  d.push_back(a[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    int x = d.front(), y = d.back();
    if (a[i] < x)
      d.push_front(a[i]);
    else if (a[i] < y)
      d.push_back(a[i]);
  }
  cout << d.size() << endl;
  for (int i = 0; i < d.size(); i++) cout << d[i] << " ";
}
