#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, bestX = 0, bestAns = 0, a[N], cnt[N], dp[N], pref[N];
int f(int x, bool flag = true) {
  if (cnt[x] == 0) return x + 1;
  if (x != 0 && cnt[x] == 1 && flag) return f(x - 1, false);
  int y = x - dp[x] + 1;
  if (y != 0 && cnt[y - 1] == 1) --y;
  return y;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i], ++cnt[a[i]];
  dp[0] = (cnt[0] >= 2);
  for (int x = 1; x < N; ++x) dp[x] = (cnt[x] >= 2 ? dp[x - 1] + 1 : 0);
  for (int i = 1; i < N; ++i) pref[i] = pref[i - 1] + cnt[i - 1];
  for (int x = 0; x < N; ++x) {
    int y = f(x);
    if (bestAns < pref[x + 1] - pref[y]) {
      bestAns = pref[x + 1] - pref[y];
      bestX = x;
    }
  }
  cout << bestAns << endl;
  int bestY = f(bestX);
  for (int y = bestY; y <= bestX; ++y) cout << y << " ", --cnt[y];
  for (int y = bestX; y >= bestY; --y) {
    while (cnt[y]) cout << y << " ", --cnt[y];
  }
  cout << endl;
  return 0;
}
