#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, mx = 0, ans = 1;
  cin >> n;
  vector<int> cnt(5001);
  for (int i = 0; i < n; ++i) {
    cin >> a;
    ++cnt[a];
    mx = max(mx, a);
  }
  for (int i = 1; i < mx; ++i)
    if (cnt[i] == 1)
      ++ans;
    else if (cnt[i] > 1)
      ans += 2;
  cout << ans << endl;
  for (int i = 1; i < mx; ++i)
    if (cnt[i]) {
      cout << i << ' ';
      --cnt[i];
    }
  cout << mx << ' ';
  for (int i = mx - 1; i > 0; --i)
    if (cnt[i]) cout << i << ' ';
  return 0;
}
