#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n), cnt(N, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  sort(a.begin(), a.end());
  long long l = 0, r = 0;
  long long lm = 0, rm = 0, len;
  long long i;
  for (i = 1; i < n; ++i) {
    if (a[i] - a[i - 1] > 1) {
      len = i - l;
      if (len > rm - lm + 1) {
        rm = i - 1;
        lm = l;
      }
      l = i;
    } else if (cnt[a[i - 1]] == 1 && a[i - 1] != a[l] && a[i - 1] != a[i]) {
      len = i - l;
      if (len > rm - lm + 1) {
        rm = i - 1;
        lm = l;
      }
      l = i - 1;
    }
  }
  if (i - l > rm - lm + 1) {
    rm = i - 1;
    lm = l;
  }
  cout << rm - lm + 1 << "\n";
  lm = a[lm];
  rm = a[rm];
  for (int i = lm; i < rm; ++i) cout << i << " ";
  for (int i = 0; i < cnt[rm]; ++i) cout << rm << " ";
  for (int i = rm - 1; i >= lm; --i) {
    for (int j = 0; j < cnt[i] - 1; ++j) cout << i << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt = 1;
  for (int tc = 1; tc <= tt; ++tc) {
    solve();
  }
}
