#include <bits/stdc++.h>
using namespace std;
long long fr[1000005], sp[1000005];
int main() {
  long long i, x, n, ans, ansit1, ansit2, it1, it2, sum = 0, act;
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x;
    fr[x]++;
  }
  for (i = 1; i <= 200000; i++) sp[i] = sp[i - 1] + fr[i];
  ans = fr[1];
  ansit1 = 1;
  ansit2 = 1;
  it1 = 1;
  it2 = 1;
  sum = 0;
  while (it1 <= 200000) {
    while (it1 <= 200000 && fr[it1] == 0) it1++;
    it2 = max(it1, it2);
    while (fr[it2] >= 2) {
      it2++;
    }
    it2--;
    sum = sp[it2] - sp[it1 - 1];
    act = sum + fr[it1 - 1] + fr[it2 + 1];
    if (act > ans) {
      ans = act;
      ansit1 = it1 - 1;
      ansit2 = it2 + 1;
    }
    it1++;
  }
  cout << ans << '\n';
  for (i = ansit1; i <= ansit2; i++) {
    while (fr[i] > 1) {
      cout << i << ' ';
      fr[i]--;
    }
  }
  for (i = ansit2; i >= ansit1; i--) {
    while (fr[i] > 0) {
      cout << i << ' ';
      fr[i]--;
    }
  }
  cout << '\n';
  return 0;
}
