#include <bits/stdc++.h>
using namespace std;
int arr[1000000], n;
deque<int> res;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  sort(arr, arr + n);
  res.push_back(arr[n - 1]);
  for (int i = n - 2; i >= 0; i--) {
    if (res.front() != arr[i])
      res.push_front(arr[i]);
    else if (res.back() != arr[i])
      res.push_back(arr[i]);
  }
  printf("%d\n", ((int)res.size()));
  while (!res.empty()) {
    printf("%d ", res.front());
    res.pop_front();
  }
  puts("");
  return 0;
}
