#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a[N], dem[N], run, ans;
vector<int> ch;
pair<int, int> ans2;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    ch.push_back(a[i]);
  }
  sort(ch.begin(), ch.end());
  ch.resize(unique(ch.begin(), ch.end()) - ch.begin());
  for (int i = 1; i <= n; ++i)
    ++dem[lower_bound(ch.begin(), ch.end(), a[i]) - ch.begin()];
  while (run < ch.size()) {
    int save = run;
    int cur = dem[run];
    while (run + 1 < ch.size() && ch[run + 1] - ch[run] == 1 &&
           dem[run + 1] >= 2) {
      cur += dem[++run];
    }
    bool temp = 0;
    if (run + 1 < ch.size() && ch[run + 1] - ch[run] == 1) ++cur, temp = 1;
    if (ans < cur) {
      ans = cur;
      ans2 = {save, run + temp};
    }
    ++run;
  }
  cout << ans << '\n';
  for (int i = ans2.second; i >= ans2.first; --i) cout << ch[i] << ' ';
  for (int i = ans2.first; i <= ans2.second; ++i)
    for (int j = 2; j <= dem[i]; ++j) cout << ch[i] << ' ';
  return 0;
}
