#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt[5001];
  memset(cnt, 0, sizeof(cnt));
  int m;
  cin >> m;
  while (m--) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  int ma = 0;
  vector<int> ans;
  for (int i = int(1); i < int(5001); i++) {
    if (cnt[i]) {
      ma = i;
      ans.push_back(i);
      cnt[i]--;
    }
  }
  for (int i = ma - 1; i >= 1; i--) {
    if (cnt[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
}
