#include <bits/stdc++.h>
using namespace std;
int main() {
  long i, j = 0, k, l = 0, m, n, p, r, b[100005] = {0}, a[100005] = {0}, t1, t2,
          te1, te2, c = 0;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    while (a[i] == a[i + 1] && i < n) i++;
    b[j] = a[i];
    j++;
  }
  k = j;
  for (i = 0; i < n; i++) {
    if (a[i] == a[i + 1] && i < n) {
      while (a[i] == a[i + 1] && i < n) i++;
      b[k] = a[i];
      k++;
    }
  }
  if (b[j - 1] == b[k - 1] && k != j)
    cout << k - 1 << '\n';
  else
    cout << k << '\n';
  for (l = j; l < k; l++) cout << b[l] << " ";
  if (k != j && b[l - 1] == b[j - 1]) j--;
  for (l = j - 1; l >= 0; l--) cout << b[l] << " ";
  return 0;
}
