#include <bits/stdc++.h>
using namespace std;
long c[5009] = {0};
int main(void) {
  long m, mn = 50000, mx = 0;
  cin >> m;
  vector<long> arr(m + 1);
  for (long i = 0; i < m; i++) {
    long x;
    cin >> x;
    arr[i] = x;
    mn = min(mn, arr[i]);
    mx = max(mx, arr[i]);
  }
  if (m == 1) {
    cout << "1 " << arr[0];
    return 0;
  }
  for (long i = 0; i < m; i++) {
    if (c[arr[i]] <= 1) c[arr[i]]++;
  }
  vector<long> ans;
  for (long i = mn; i <= mx; i++) {
    if (c[i]) {
      ans.push_back(i);
      c[i]--;
    }
  }
  for (long i = mx - 1; i >= mn; i--) {
    if (c[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for (long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
