#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> v(n + 1);
  for (long long i = 1; i <= n; ++i) cin >> v[i];
  sort(v.begin() + 1, v.begin() + n + 1);
  long long ans = 0;
  long long i = 1;
  long long j = 1;
  long long st = 1;
  map<long long, long long> hm;
  while (j <= n) {
    long long d = v[j] - v[i];
    if (d >= 2) {
      long long g = v[j] - 1;
      if (hm[g] >= 2) {
        if (ans < j - i + 1) {
          ans = j - i + 1;
          st = i;
        }
      } else {
        if (hm[g] == 0) {
          while (i < j) {
            hm[v[i]]--;
            i++;
          }
        } else {
          while (v[i] != g) {
            hm[v[i]]--;
            i++;
          }
        }
      }
    } else {
      if (ans < j - i + 1) {
        ans = j - i + 1;
        st = i;
      }
    }
    hm[v[j]]++;
    j++;
  }
  vector<long long> res;
  map<long long, long long> mp;
  long long end = st + ans - 1;
  for (long long i = st; i <= end; ++i) {
    mp[v[i]]++;
  }
  long long diff = v[end] - v[st];
  ;
  while (mp[v[st]] > 0) {
    res.push_back(v[st]);
    mp[v[st]]--;
  }
  if (diff > 0) {
    long long curr_elem = v[st] + 1;
    long long fin_elem = v[end];
    while (curr_elem != fin_elem) {
      res.push_back(curr_elem);
      mp[curr_elem]--;
      curr_elem++;
    }
    while (fin_elem != v[st]) {
      while (mp[fin_elem] > 0) {
        res.push_back(fin_elem);
        mp[fin_elem]--;
      }
      fin_elem--;
    }
  };
  ;
  cout << ans << endl;
  for (auto x : res) cout << x << " ";
  cout << endl;
}
int main() {
  init();
  long long t = 1;
  while (t--) {
    solve();
  }
}
