#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> arr(n);
  vector<int> cnt(2e5 + 1);
  for (auto &ele : arr) {
    cin >> ele;
    ++cnt[ele];
  }
  sort(arr.begin(), arr.end());
  arr.resize(unique(arr.begin(), arr.end()) - arr.begin());
  int ansl = 0, ansr = 0, ans = cnt[arr[0]];
  for (int i = 0; i < arr.size(); ++i) {
    int nowr = i + 1;
    int sum = cnt[arr[i]];
    while (arr[nowr] - arr[nowr - 1] == 1 && cnt[arr[nowr]] > 1) {
      ++nowr;
      sum += cnt[arr[nowr - 1]];
    }
    int cr = nowr - 1;
    if (nowr < n && arr[nowr] - arr[nowr - 1] == 1) {
      sum += cnt[arr[nowr]];
      ++cr;
    }
    if (ans < sum) {
      ans = sum;
      ansl = i;
      ansr = cr;
    }
    i = nowr - 1;
  }
  cout << ans << endl;
  for (int i = 1; i <= cnt[arr[ansl]]; ++i) cout << arr[ansl] << " ";
  for (int i = ansl + 1; i < ansr; i++) {
    for (int j = 1; j < cnt[arr[i]]; ++j) cout << arr[i] << " ";
  }
  if (ansl != ansr)
    for (int j = 1; j <= cnt[arr[ansr]]; ++j) cout << arr[ansr] << " ";
  for (int i = ansr - 1; i > ansl; --i) cout << arr[i] << " ";
  return 0;
}
