#include <bits/stdc++.h>
using namespace std;
long long m, max1 = 0;
vector<long long> b, b1, ans;
int main() {
  cin >> m;
  b.resize(m);
  for (int i = 0; i < m; i++) cin >> b[i];
  sort(b.begin(), b.end());
  b1.resize(m);
  b1 = b;
  for (int i = m - 1; i > 0; i--)
    if (b[i] == b[i - 1]) {
      b[i + 1] = 0;
      b1.push_back(b[i]);
    }
  for (int i = 1; i < b1.size(); i++)
    if (b1[i - 1] == b1[i]) b1[i - 1] = 0;
  if (b1 == b)
    for (int i = b[max1]; i > 0; i--)
      if (b[i] > b[i - 1]) {
        b1[i - 1] = 0;
        b1.push_back(b[i - 1]);
      }
  for (int i = 0; i < b1.size(); i++)
    if (b1[i] != 0) ans.push_back(b1[i]);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
