#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
int main() {
  int n;
  cin >> n;
  set<int> s, s1;
  map<int, int> m;
  vector<int> v;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
    m[a[i]]++;
  }
  int largest;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    v.push_back(*it);
    largest = (*it);
    m[(*it)]--;
  }
  for (set<int>::iterator it1 = s.begin(); it1 != s.end(); it1++) {
    if (m[(*it1)] > 0) s1.insert(*it1);
  }
  if (s1.size() > 0) {
    set<int>::iterator it2 = s1.end();
    set<int>::iterator it3 = it2;
    it3--;
    if ((*it3) == largest) it2--;
    while (it2 != s1.begin()) {
      it2--;
      v.push_back(*it2);
    }
    cout << (v.size()) << "\n";
    for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  } else {
    cout << (v.size()) << "\n";
    for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  }
}
