#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int cnt[N];
int n, res, firstInd;
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  int actFirst = 0;
  int act = 0;
  for (int i = 0; i < N; ++i) {
    act += cnt[i];
    if (act > res) {
      res = act;
      firstInd = actFirst;
    }
    if (cnt[i] < 2 && actFirst != i) {
      act = cnt[i];
      actFirst = i + !cnt[i];
      continue;
    }
  }
  vector<int> res;
  bool flag = 0;
  while (1) {
    if (cnt[firstInd]) {
      res.push_back(firstInd);
      cnt[firstInd]--;
    }
    if (cnt[firstInd] == 0 && flag) {
      break;
    }
    flag = 1;
    firstInd++;
  }
  firstInd--;
  while (firstInd > 0 && cnt[firstInd]) {
    for (int j = 0; j < cnt[firstInd]; ++j) {
      res.push_back(firstInd);
    }
    firstInd--;
  }
  cout << res.size() << "\n";
  for (auto i : res) {
    cout << i << " ";
  }
  return 0;
}
