#include <bits/stdc++.h>
static constexpr int max_n = 2 * 100000;
static int a[max_n], res[max_n];
int main() {
  int n;
  std::cin >> n;
  for (decltype(n) i = 0; i < (n); i++) std::cin >> a[i];
  std::sort(a, a + n);
  int l = 0, r = 1;
  int k = 0, prev = a[0];
  for (int i = 0; i < n;) {
    if (std::abs(prev - a[i]) > 1) k = i;
    prev = a[i];
    int j = i;
    while (i < n && a[i] == a[j]) i++;
    if (i - k > r - l) r = i, l = k;
    if (i - j == 1) k = j;
  }
  int len = r - l, res_l = 0, res_r = len - 1;
  for (auto i = (0); i < (len); i++) {
    if (i % 2 == 0)
      res[res_r--] = a[l + i];
    else
      res[res_l++] = a[l + i];
  }
  std::cout << len << std::endl;
  for (auto i = (0); i < (len); i++) std::cout << res[i] << ' ';
  std::cout << std::endl;
}
