#include <bits/stdc++.h>
using namespace std;
int countarun[6000];
int main() {
  int n, i, m = 0;
  cin >> n;
  int a[n];
  memset(countarun, 0, sizeof(countarun));
  int ans = n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    m = max(m, a[i]);
    countarun[a[i]]++;
  }
  for (i = 0; i < m; i++) {
    if (countarun[i] > 2) ans -= (countarun[i] - 2);
  }
  if (countarun[m] > 1) ans -= (countarun[m] - 1);
  cout << ans << endl;
  for (i = 1; i < m; i++) {
    if (countarun[i]) {
      cout << i << " ";
      countarun[i]--;
    }
  }
  cout << m << " ";
  for (i = m - 1; i > 0; i--) {
    if (countarun[i]) cout << i << " ";
    countarun[i]--;
  }
  return 0;
}
