#include <bits/stdc++.h>
using namespace std;
const long long M = 100100 * 5;
const long long N = 50005;
long long m, b, k;
map<long long, long long> fre;
int v1[M], mmax;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b;
    fre[b]++;
  }
  for (int i = 0; i < N; i++) {
    if (fre[i]) v1[k] = i, k++, fre[i]--, mmax = max(mmax, i);
  }
  for (int i = mmax - 1; i >= 0; i--) {
    if (fre[i]) v1[k] = i, k++;
  }
  cout << k << endl;
  for (int i = 0; i < k; i++) cout << v1[i] << " ";
}
