#include <bits/stdc++.h>
using namespace std;
int rep[5005], n, x, y;
deque<int> q;
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 0, t; i < n; i++) cin >> t, rep[t]++;
  for (int i = 5000; i; i--)
    if (rep[i])
      if (q.empty() || rep[i] == 1)
        q.push_back(i);
      else {
        q.push_front(i);
        q.push_back(i);
      }
  cout << q.size() << '\n';
  for (int i = 0; i < q.size(); i++) cout << q[i] << ' ';
  cout << '\n';
  return 0;
}
