#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  vector<long long> arr;
  long long max_ele = INT64_MIN;
  map<long long, long long> freq;
  vector<long long> req_no;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    if (x > max_ele) max_ele = x;
    arr.push_back(x);
    freq[x]++;
  }
  for (auto i : freq) {
    if (i.first == max_ele) {
      req_no.push_back(i.first);
      continue;
    }
    if (i.second <= 2) {
      if (i.second == 2) {
        req_no.push_back(i.first);
        req_no.push_back(i.first);
      } else if (i.second == 1) {
        req_no.push_back(i.first);
      }
    } else {
      req_no.push_back(i.first);
      req_no.push_back(i.first);
    }
  }
  cout << req_no.size() << endl;
  deque<long long> final;
  long long visit = INT64_MIN;
  for (long long i = req_no.size() - 1; i >= 0; i--) {
    if (req_no[i] != visit) {
      final.push_back(req_no[i]);
      visit = req_no[i];
    } else {
      final.push_front(req_no[i]);
    }
  }
  while (final.size()) {
    cout << final.front() << " ";
    final.pop_front();
  }
  return 0;
}
