#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> fl, sl;
  int num, ret = 0, n;
  map<int, int> m;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> num;
    m[num]++;
  }
  bool sub = false;
  map<int, int>::iterator it;
  for (it = m.begin(); it != m.end(); it++) {
    if (it->second >= 2) {
      sl.push_back(it->first);
    }
    fl.push_back(it->first);
    ret += min(it->second, 2);
  }
  it = m.end();
  --it;
  int s;
  if (it->second >= 2)
    s = sl.size() - 2, sub = true;
  else
    s = sl.size() - 1;
  cout << ret - (sub == true) << endl;
  for (long long i = 0; i < fl.size(); i++) cout << fl[i] << " ";
  for (; s >= 0; s--) cout << sl[s] << " ";
  cout << endl;
  return 0;
}
