#include <bits/stdc++.h>
using namespace std;
int cnt[5002];
int main() {
  int n, mx = -1, mn = 50005, sz;
  scanf("%d", &n);
  vector<int> arr(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &arr[i]), cnt[arr[i]]++, mx = max(mx, arr[i]),
                                         mn = min(mn, arr[i]);
  sort(arr.begin(), arr.end());
  arr.resize(unique(arr.begin(), arr.end()) - arr.begin());
  for (int i = mx - 1; i >= mn; i--)
    if (cnt[i] > 1) arr.push_back(i);
  sz = arr.size();
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) printf("%d ", arr[i]);
  return 0;
}
