#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
long long n, i, j, a[maxn], res(0), kt[maxn], x(0), y(0), minn(1e9), maxx(0);
deque<int> q;
void read() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    minn = min(minn, a[i]);
    maxx = max(maxx, a[i]);
    kt[a[i]]++;
  }
  sort(a + 1, a + n + 1);
}
void solve() {
  i = j = minn;
  long long ans = 0;
  while (i <= maxx) {
    if (kt[i] == 0) {
      ans = 0;
      i++;
    } else {
      j = i + 1;
      ans += kt[i];
      while (kt[j] > 1) {
        ans += kt[j];
        j++;
      }
      if (kt[j] == 1) ans++;
      if (ans > res) {
        res = ans;
        x = i;
        y = j;
      }
      i = j;
      ans = 0;
    }
  }
}
void printf() {
  cout << res << endl;
  for (i = x; i <= y; i++) {
    while (kt[i] > 1) {
      q.push_back(i);
      kt[i]--;
    }
    if (kt[i] == 1) q.push_front(i);
  }
  for (auto u : q) cout << u << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  read();
  solve();
  printf();
}
