#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
vector<int> solve(vector<int> &a) {
  int n = a.size(), start = a.front();
  vector<int> cnt;
  int now = a.front(), tmp = 1;
  for (int i = (1); i < (n); ++i) {
    if (now == a[i]) {
      ++tmp;
    } else {
      cnt.emplace_back(tmp);
      tmp = 1;
      now = a[i];
    }
  }
  cnt.emplace_back(tmp);
  int sz = cnt.size(), hajimari = 0, owari = 0, mx = 0;
  for (int i = 0; i < sz;) {
    int j = i + 1, kokono = cnt[i];
    while (j < sz) {
      kokono += cnt[j];
      if (cnt[j] == 1) {
        ++j;
        break;
      }
      ++j;
    }
    if (kokono > mx) {
      mx = kokono;
      hajimari = i;
      owari = j;
    }
    if (j == sz) break;
    i = j - 1;
  }
  vector<int> res;
  for (int i = (hajimari); i < (owari); ++i) {
    int now = start + i;
    res.emplace_back(now);
  }
  for (int i = owari - 1; i >= hajimari; --i) {
    int now = start + i;
    for (int j = (0); j < (cnt[i] - 1); ++j) res.emplace_back(now);
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  vector<int> tmp{a.front()}, ans{a.front()};
  for (int i = (1); i < (n); ++i) {
    if (a[i] - tmp.back() <= 1) {
      tmp.emplace_back(a[i]);
    } else {
      vector<int> cand = solve(tmp);
      if (cand.size() > ans.size()) ans = cand;
      tmp.assign(1, a[i]);
    }
  }
  vector<int> cand = solve(tmp);
  if (cand.size() > ans.size()) ans = cand;
  cout << ans.size() << '\n';
  for (int i = (0); i < (ans.size()); ++i)
    cout << ans[i] << (i == ans.size() - 1 ? '\n' : ' ');
  return 0;
}
