#include <bits/stdc++.h>
using namespace std;
ifstream Cin("input.txt");
ofstream Cout("output.txt");
const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7;
int main() {
  long long n, i, k[5001] = {}, mx = 0;
  cin >> n;
  vector<long long> r(n), ans;
  for (i = 0; i < n; ++i) cin >> r[i], k[r[i]]++, mx = max(mx, r[i]);
  for (i = 1; i <= 5000; ++i)
    if (i == mx)
      break;
    else if (k[i])
      ans.push_back(i), k[i]--;
  for (i = 5000; i >= 1; i--)
    if (k[i]) ans.push_back(i);
  cout << (long long)ans.size() << endl;
  for (i = 0; i < (long long)ans.size(); ++i) cout << ans[i] << " ";
}
