#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 5;
int cnt[N];
vector<int> vec;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vec.push_back(0);
  int minn = INF, maxx = 0;
  for (int i = 0; i < (int)(n); ++i) {
    int x;
    cin >> x;
    cnt[x]++;
    minn = min(minn, x);
    maxx = max(maxx, x);
  }
  if (cnt[minn] != 1) vec.push_back(minn);
  int flag = 1;
  for (int i = 1; i <= (int)(2e5); ++i) {
    if (cnt[i] == 1)
      vec.push_back(i);
    else {
      if (i != 1 && cnt[i] != 0 && cnt[i - 1] == 0)
        vec.push_back(i);
      else if (i != 2e5 && cnt[i] != 0 && cnt[i + 1] == 0)
        vec.push_back(i);
    }
  }
  if (cnt[maxx] != 1) vec.push_back(maxx);
  int ans = 0;
  int l, r;
  for (int i = 0; i < (int)(vec.size() - 1); ++i) {
    int tmp = 0;
    int flag = 0;
    for (int j = (int)(vec[i]); j <= (int)(vec[i + 1]); ++j) {
      if (cnt[j] == 0) {
        flag = 1;
        break;
      }
      tmp += cnt[j];
    }
    if (flag == 0) {
      if (tmp > ans) {
        ans = tmp;
        l = vec[i];
        r = vec[i + 1];
      }
    }
  }
  for (int i = 1; i <= (int)(2e5); ++i) {
    if (cnt[i] > ans) {
      ans = cnt[i];
      l = i;
      r = i;
    }
  }
  cout << ans << '\n';
  for (int i = (int)(l); i <= (int)(r); ++i) {
    cout << i << ' ';
    cnt[i]--;
  }
  for (int i = r; i >= l; --i) {
    while (cnt[i]) {
      cout << i << ' ';
      cnt[i]--;
    }
  }
}
