#include <bits/stdc++.h>
using namespace std;
int v[200000 + 5], nrap[200000 + 5], spn[200000 + 5];
int aint[4 * 200000 + 5];
int q;
void build(int p, pair<int, int> itv) {
  if (itv.first == itv.second) {
    aint[p] = nrap[itv.first];
    return;
  }
  int mid = (itv.first + itv.second) / 2;
  build(p * 2, {itv.first, mid});
  build(p * 2 + 1, {mid + 1, itv.second});
  aint[p] = min(aint[p * 2], aint[p * 2 + 1]);
}
void query(int p, pair<int, int> itv, pair<int, int> ok) {
  if (ok.first > itv.second || itv.first > ok.second) return;
  if (itv.first >= ok.first && itv.second <= ok.second) {
    q = min(q, aint[p]);
    return;
  }
  int mid = (itv.first + itv.second) / 2;
  query(p * 2, {itv.first, mid}, ok);
  query(p * 2 + 1, {mid + 1, itv.second}, ok);
}
int main() {
  int n;
  cin >> n;
  int i, j, z, m = (INT_MAX / 2 - 1), M = 0;
  for (i = 1; i <= n; i++) cin >> v[i], m = min(m, v[i]), M = max(M, v[i]);
  sort(v + 1, v + n + 1);
  for (i = 1; i <= n; i++) nrap[v[i]]++;
  for (i = m; i <= M; i++) spn[i] = spn[i - 1] + nrap[i];
  build(1, {m, M});
  int pas, ans = 1;
  pair<int, int> cur = make_pair(v[1], v[1]);
  for (i = 1; i <= n; i++) {
    for (j = i, pas = (1 << 18); pas > 0; pas /= 2) {
      if (j + pas <= n && v[i] + 1 <= v[j + pas] - 1) {
        q = (INT_MAX / 2 - 1);
        query(1, {m, M}, {v[i] + 1, v[j + pas] - 1});
      }
      if (j + pas <= n && (v[j + pas] <= 1 + v[i] || q >= 2)) j += pas;
    }
    if (ans < spn[v[j]] - spn[v[i] - 1])
      ans = spn[v[j]] - spn[v[i] - 1], cur = {v[i], v[j]};
  }
  cout << ans << '\n';
  for (z = 0; z < nrap[cur.first]; z++) cout << cur.first << ' ';
  nrap[cur.first] = 0;
  for (i = cur.first + 1; i < cur.second; i++) cout << i << ' ';
  for (z = 0; z < nrap[cur.second]; z++) cout << cur.second << ' ';
  nrap[cur.second] = 0;
  for (i = cur.second - 1; i > cur.first; i--)
    for (z = 0; z + 1 < nrap[i]; z++) cout << i << ' ';
  return 0;
}
