#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
int main() {
  std::ios::sync_with_stdio(false);
  int cnt[N];
  int n;
  int num;
  memset(cnt, 0, sizeof cnt);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    cnt[num]++;
  }
  std::vector<int> ans;
  for (int i = 0; i < N; i++) {
    if (cnt[i] > 0) {
      ans.push_back(i);
      cnt[i]--;
    }
  }
  for (int i = ans[ans.size() - 1] - 1; i >= 0; i--) {
    if (cnt[i] > 0) {
      ans.push_back(i);
      cnt[i]--;
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
