#include <bits/stdc++.h>
using std::abs;
using std::cerr;
using std::cin;
using std::cout;
using std::function;
using std::lower_bound;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::reverse;
using std::set;
using std::sort;
using std::stoi;
using std::string;
using std::to_string;
using std::vector;
using ll = long long;
using PI = pair<int, int>;
template <class T>
using V = vector<T>;
using VI = V<int>;
int MOD = (int)1e9 + 7;
template <class T>
inline void debug(T &A) {}
template <class T>
inline void debug_dim2(T &A) {}
template <typename... Args>
inline void debug(const char *format, Args const &...args) {}
template <typename... Args>
string format(const std::string &fmt, Args... args) {
  size_t len = std::snprintf(nullptr, 0, fmt.c_str(), args...);
  std::vector<char> buf(len + 1);
  std::snprintf(&buf[0], len + 1, fmt.c_str(), args...);
  return std::string(&buf[0], &buf[0] + len);
}
V<ll> cum_sum(VI &A) {
  V<ll> res(A.size() + 1);
  res[0] = 0;
  for (int i = 0; i < (int)A.size(); ++i) {
    res[i + 1] = res[i] + A[i];
  }
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int MAX = (int)2e5;
  int N;
  cin >> N;
  VI C(MAX);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    C[--a]++;
  }
  auto cum = cum_sum(C);
  PI rg(0, 0);
  int r = 0;
  for (int l = 0; l < MAX; ++l) {
    if (C[l] == 0) continue;
    r = max(r, l);
    while (r + 1 < MAX && C[r + 1] >= 2) r++;
    debug("l:%d r:%d len:%d", l, r, cum[r + 1] - cum[l]);
    int r2 = r + 1 < MAX && C[r + 1] == 1 ? 1 : 0;
    if (cum[rg.second + 1] - cum[rg.first] < cum[r + r2 + 1] - cum[l]) {
      rg.first = l, rg.second = r + r2;
    }
  }
  debug("l:%d r:%d", rg.first, rg.second);
  cout << cum[rg.second + 1] - cum[rg.first] << '\n';
  for (int i = rg.first; i <= rg.second; ++i) {
    cout << i + 1 << " ";
    C[i]--;
  }
  for (int i = rg.second; i >= rg.first; --i) {
    while (C[i]) {
      cout << i + 1 << " ";
      C[i]--;
    }
  }
  return 0;
}
