#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 1, mx = 0, l = 0, ansl, ansr, x;
  cin >> n;
  vector<int> h;
  for (int i = 0; i < n; i++) {
    cin >> x;
    h.push_back(x);
  }
  if (n == 1) {
    cout << 1 << endl << h[0];
    return 0;
  }
  sort(h.begin(), h.end());
  for (int i = 1; i < n; i++) {
    if (i == n - 1) {
      if (h[i] - h[i - 1] > 1) {
        if (cnt > mx) {
          mx = cnt;
          ansl = l;
          ansr = i - 1;
        }
      } else {
        cnt++;
        if (cnt > mx) {
          mx = cnt;
          ansl = l;
          ansr = i;
        }
      }
    } else if (h[i] != h[i - 1] && h[i] != h[i + 1]) {
      if (h[i] - h[i - 1] > 1) {
        if (cnt > mx) {
          mx = cnt;
          ansl = l;
          ansr = i - 1;
          cnt = 1;
          l = i;
        }
        cnt = 1;
        l = i;
      } else {
        cnt++;
        if (cnt > mx) {
          mx = cnt;
          ansl = l;
          ansr = i;
        }
        cnt = 1;
        l = i;
      }
    } else if (h[i] - h[i - 1] > 1) {
      if (cnt > mx) {
        mx = cnt;
        ansl = l;
        ansr = i - 1;
      }
      cnt = 1;
      l = i;
    } else {
      cnt++;
    }
  }
  vector<int> ans;
  for (int i = ansl + 1; i <= ansr; i++) {
    if (h[i] == h[i - 1]) {
      ans.push_back(h[i]);
    }
  }
  for (int i = ansr; i >= ansl; i--)
    if (h[i] != h[i - 1]) ans.push_back(h[i]);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
