#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], b[5005] = {0}, p = -10;
  vector<int> m, j;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
    if (b[a[i]] == 1) {
      m.push_back(a[i]);
    } else if (b[a[i]] == 2) {
      j.push_back(a[i]);
    }
  }
  sort(m.begin(), m.end(), greater<int>());
  sort(j.begin(), j.end());
  int x = m.size() + j.size();
  if (j.size() != 0 && m[0] == j[j.size() - 1]) {
    cout << x - 1 << "\n";
    for (int i = 0; i < j.size() - 1; i++) {
      cout << j[i] << " ";
    }
    for (int i = 0; i < m.size(); i++) {
      cout << m[i] << " ";
    }
    cout << "\n";
  } else {
    cout << x << "\n";
    for (int i = 0; i < j.size(); i++) {
      cout << j[i] << " ";
    }
    for (int i = 0; i < m.size(); i++) {
      cout << m[i] << " ";
    }
    cout << "\n";
  }
}
