#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
inline int safe_mul(const int x, const int y)
    __attribute__((warn_unused_result));
int const maxn = 200005;
int cnt[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    ++cnt[x];
  }
  int best = 0;
  int lb = 0;
  int rb = 0;
  for (int i = 0; i + 1 < maxn;) {
    if (cnt[i] == 0) {
      ++i;
      continue;
    }
    int cur = cnt[i];
    int j = i + 1;
    for (; cnt[j] > 1; ++j) {
      cur += cnt[j];
    }
    if (cnt[j] == 1) ++cur;
    if (cur > best) {
      best = cur;
      lb = i;
      rb = cnt[j] == 0 ? j - 1 : j;
    }
    i = j;
  }
  cout << best << endl;
  vector<int> res;
  for (int i = lb; i <= rb; ++i) {
    --cnt[i];
    res.push_back(i);
  }
  for (int i = rb; i >= lb; --i) {
    while (cnt[i] > 0) {
      res.push_back(i);
      --cnt[i];
    }
  }
  for (int x : res) cout << x << ' ';
}
