#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n, greater<int>());
  deque<int> d;
  d.push_front(arr[0]);
  int i;
  for (i = 1; i < n; i++) {
    if (arr[i] != arr[0]) break;
  }
  while (i < n) {
    int a = arr[i];
    d.push_back(a);
    if (arr[i] == arr[i + 1]) d.push_front(a);
    for (; i < n; i++) {
      if (arr[i] != a) break;
    }
  }
  cout << d.size() << endl;
  while (d.size() > 0) {
    cout << d.front() << " ";
    d.pop_front();
  }
}
