#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const double eps = 0.0000000001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int m;
  cin >> m;
  vector<int> b(m), lhs, rhs;
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  sort(b.begin(), b.end(), [](int a, int b) { return a > b; });
  rhs.push_back(b[0]);
  int counter = 1;
  for (int i = 1; i < m; ++i) {
    if (b[i] == b[i - 1]) {
      if (counter == 1) {
        counter++;
        lhs.push_back(b[i]);
      } else {
        continue;
      }
    } else {
      counter = 1;
      rhs.push_back(b[i]);
    }
  }
  bool eq;
  if (lhs.size()) {
    eq = (rhs[0] == lhs[0]);
  } else {
    eq = 0;
  }
  cout << (lhs.size() + rhs.size() - eq) << endl;
  for (int i = lhs.size() - 1; i >= eq; --i) {
    cout << lhs[i] << ' ';
  }
  for (size_t i = 0; i < rhs.size(); ++i) {
    cout << rhs[i] << ' ';
  }
}
