#include <bits/stdc++.h>
using namespace std;
int n, ans = 0;
int a[100005], M[5005], maxx = -1;
vector<int> V1, V2;
void thuchien() {
  V1.push_back(maxx);
  for (int i = 1; i <= 5000; i++)
    if (i != maxx) {
      if (M[i] >= 2) {
        V1.push_back(i);
        V2.push_back(i);
      } else if (M[i] == 1)
        V1.push_back(i);
    }
  sort(V1.begin(), V1.end());
  sort(V2.begin(), V2.end());
  reverse(V2.begin(), V2.end());
  cout << V1.size() + V2.size() << endl;
  for (int i = 0; i < V1.size(); i++) cout << V1[i] << " ";
  for (int i = 0; i < V2.size(); i++) cout << V2[i] << " ";
}
int main() {
  ios::sync_with_stdio(false);
  memset(M, 0, sizeof(M));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    M[a[i]]++;
    maxx = max(maxx, a[i]);
  }
  thuchien();
  return 0;
}
