#include <bits/stdc++.h>
using namespace std;
const long long int inf = (long long int)1e18 + 19;
const long long int mod = (long long int)1e9 + 7;
void cazz() {
  long long int t = 1, i, j, n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  deque<long long int> q;
  q.push_back(a[n - 1]);
  bool f = 0;
  for (long long int i = n - 1 - 1; i >= 0; i--) {
    if (!f) {
      while (q.back() == a[i] && i >= 0) i--;
      if (i >= 0) {
        q.push_back(a[i]);
        f = 1;
      }
    } else if (f) {
      while (q.front() == a[i] && i >= 0) i--;
      if (i >= 0) {
        q.push_front(a[i]);
        f = 0;
      }
    }
  }
  cout << q.size() << "\n";
  deque<long long int>::iterator it;
  for (it = q.begin(); it != q.end(); it++) cout << *it << ' ';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cazz();
  return 0;
}
