#include <bits/stdc++.h>
using namespace std;
int n, a[100005], b[100005], c[100005];
int main() {
  int i, j, p;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  j = 0;
  p = 0;
  for (i = 0; i < n; i++) {
    c[p] = a[i];
    p++;
    if (a[i] == a[i + 1] && i < (n - 1)) {
      b[j] = a[i];
      j++;
      while (a[i] == a[i + 1] && i < (n - 1)) {
        i++;
      }
    }
  }
  if (j == 0) {
    cout << p << endl;
    for (i = 0; i < p; i++) {
      cout << c[i] << " ";
    }
    cout << endl;
    return 0;
  }
  if (b[j - 1] == a[n - 1]) {
    j--;
  }
  for (i = j - 1; i >= 0; i--) {
    c[p] = b[i];
    p++;
  }
  cout << p << endl;
  for (i = 0; i < p; i++) {
    cout << c[i] << " ";
  }
  cout << endl;
  return 0;
}
