#include <bits/stdc++.h>
using namespace std;
const int nsz = 2e5;
int n, a[nsz + 5], cnt[nsz + 5];
deque<int> ans;
int inline read() {
  int res = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar())
    ;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  n = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    ++cnt[a[i]];
  }
  for (int i = 1; i <= nsz; ++i) {
    int from = i, to, sz = cnt[i];
    if (!sz) continue;
    for (int j = i + 1; j <= nsz; ++j) {
      if (cnt[j] >= 2) {
        sz += cnt[j];
        ++i;
      } else
        break;
    }
    to = i;
    if (cnt[i + 1]) {
      sz += cnt[i + 1];
      to = i + 1;
    }
    if (sz > ans.size()) {
      ans.clear();
      for (int j = from; j <= to; ++j) {
        ans.push_front(j);
        for (int k = 1; k <= cnt[j] - 1; ++k) {
          ans.push_back(j);
        }
      }
    }
  }
  cout << ans.size() << '\n';
  while (!ans.empty()) {
    cout << ans.front() << ' ';
    ans.pop_front();
  }
  cout << '\n';
}
