#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, *a, last, count = 0, k, flag = 0, b[5003];
  cin >> n;
  a = new int[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  last = a[n - 1];
  for (int i = 0; i < n; i++) b[a[i]] = 0;
  for (int i = 0; i < n; i++) b[a[i]]++;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] == a[i + 1]) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    cout << n << endl;
    for (int i = n - 1; i >= 0; i--) cout << a[i] << " ";
  } else {
    for (int i = 0; i < n; i++)
      if (last == a[i]) count++;
    for (int i = 0; i < n; i++) {
      if (b[a[i]] > 2) {
        k += b[a[i]] - 2;
        i += b[a[i]] - 1;
      }
    }
    n = n - count + 1;
    if (count > 2) k = k - count + 2;
    cout << n - k << endl;
    k = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > k) {
        cout << a[i] << " ";
        k = a[i];
        a[i] = 0;
      }
    }
    k = last;
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] != 0 && a[i] < k) {
        cout << a[i] << " ";
        k = a[i];
        a[i] = 0;
      }
    }
  }
  return 0;
}
