#include <bits/stdc++.h>
using namespace std;
int a[5001] = {0}, n;
vector<int> v;
int main() {
  int n, k, maxx = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> k, a[k]++, maxx = max(maxx, k);
  for (int i = 1; i <= maxx; i++)
    if (a[i]) v.push_back(i), a[i]--;
  for (int i = maxx - 1; i > 0; i--)
    if (maxx != i && a[i]) v.push_back(i);
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
}
