#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<pair<int, int>> b;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0, j = 0; i < n; i = j) {
    for (; j < n && a[j] == a[i]; j++)
      ;
    b.push_back({a[i], j - i});
  }
  n = b.size();
  vector<int> ans(n);
  ans[0] = b[0].second;
  for (int i = 1; i < n; i++) {
    if (b[i - 1].first == b[i].first - 1) {
      if (b[i - 1].second > 1)
        ans[i] = b[i].second + ans[i - 1];
      else
        ans[i] = b[i].second + 1;
    } else {
      ans[i] = b[i].second;
    }
  }
  pair<int, int> result = {0, 0};
  for (int i = 0; i < n; i++) {
    if (ans[i] > result.first) {
      result.first = ans[i];
      result.second = i;
    }
  }
  cout << result.first << endl;
  for (int i = 0; i < b[result.second].second; i++) {
    cout << b[result.second].first << " ";
  }
  int it = result.second - 1;
  for (; it >= 0 && (b[it].first == b[it + 1].first - 1) && (b[it].second > 1);
       it--) {
    for (int j = 0; j < b[it].second - 1; j++) {
      cout << b[it].first << " ";
    }
  }
  if (it < 0 || (b[it].first != b[it + 1].first - 1)) it++;
  for (; it < result.second; it++) {
    cout << b[it].first << " ";
  }
  cout << endl;
  return 0;
}
