#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, j;
  cin >> n;
  int arr[100010]{};
  vector<int> a;
  bool g = false;
  for (int i = 0; i < n; i++) {
    cin >> j;
    arr[j]++;
    if (arr[j] < 3) {
      a.push_back(j);
    }
  }
  sort(a.begin(), a.end());
  int mayor = a[a.size() - 1];
  vector<int> b, r;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == mayor) {
      break;
    }
    r.push_back(a[i]);
    if (a[i] == a[i + 1]) {
      g = true;
      b.push_back(a[i + 1]);
      i++;
    }
  }
  r.push_back(mayor);
  sort(b.rbegin(), b.rend());
  for (int i = 0; i < b.size(); i++) {
    r.push_back(b[i]);
  }
  if (g == 0) {
    sort(r.rbegin(), r.rend());
  }
  cout << r.size() << endl;
  for (int i = 0; i < r.size(); i++) {
    cout << r[i] << " ";
  }
  return 0;
}
