#include <bits/stdc++.h>
using namespace std;
const int arrn = 2e5 + 3;
template <typename T>
T _rv(vector<T> &in) {
  T _readin;
  cin >> _readin;
  in.push_back(_readin);
  return _readin;
}
vector<int> in;
vector<pair<int, int>> temp;
pair<int, int> dp[arrn];
int countm[arrn] = {};
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) _rv(in);
  sort(in.begin(), in.end());
  for (int i = 0; i < n; i++) {
    if (temp.empty() || temp.back().first != in[i])
      temp.push_back({in[i], 1});
    else
      temp.back().second++;
  }
  reverse(temp.begin(), temp.end());
  int val[arrn] = {};
  int outind = 0;
  int valind = 0;
  for (int i = 0; i < temp.size(); i++) {
    countm[temp[i].first] = temp[i].second;
    if (i == 0) {
      dp[i] = {temp[i].first, temp[i].first};
      val[i] = temp[i].second;
    } else {
      int a1 = dp[i - 1].first, a2 = dp[i - 1].second;
      int ind = temp[i].first;
      if (a1 - ind <= 1 && a2 - ind <= 1) {
        if (temp[i].second == 1) {
          dp[i] = {ind, a2};
          val[i] = val[i - 1] + 1;
        } else {
          dp[i] = {ind, ind};
          val[i] = val[i - 1] + temp[i].second;
        }
      } else if (a1 - ind <= 1) {
        if (temp[i].second == 1) {
          dp[i] = {ind, a1};
          val[i] = 1 + 1;
        } else {
          dp[i] = {ind, ind};
          val[i] = 1 + temp[i].second;
        }
      } else {
        dp[i] = {temp[i].first, temp[i].first};
        val[i] = temp[i].second;
      }
    }
    if (valind < val[i]) {
      outind = i;
      valind = val[i];
    }
  }
  vector<int> out1;
  vector<int> out2;
  int counta = val[outind];
  while (counta != 0) {
    pair<int, int> t = dp[outind];
    if (t.first != t.second) {
      out1.push_back(t.first);
      counta--;
    } else {
      out1.push_back(t.first);
      for (int i = 0; i < countm[t.first] - 1; i++) {
        out2.push_back(t.first);
      }
      counta -= countm[t.first];
    }
    outind--;
  }
  cout << out1.size() + out2.size() << '\n';
  for (int i = 0; i < out1.size(); i++) cout << out1[i] << " ";
  reverse(out2.begin(), out2.end());
  for (int i = 0; i < out2.size(); i++) cout << out2[i] << " ";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
