#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, n, j;
  cin >> n;
  long long v[n];
  map<long long, long long> ma;
  long long mx = -1;
  long long l, r;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    ma[v[i]]++;
  }
  sort(v, v + n);
  long long prev = -1;
  long long f = 1, c = 0, ml, mr;
  for (auto it : ma) {
    long long a = it.first, b = it.second;
    if (prev == -1)
      prev = a, l = a, r = a, c = ma[a];
    else if (a - prev == 1) {
      if (ma[a] >= 2)
        c += ma[a], r = a;
      else
        f++, c++, r = a;
      prev = a;
      if (mx < c) mx = c, ml = l, mr = r;
      if (f == 2) {
        f = 1;
        prev = a;
        c = ma[a];
        l = a;
        r = a;
      }
    } else
      prev = a, f = 1, l = a, c = ma[a], r = a;
  }
  if (mx != -1)
    cout << mx << endl;
  else {
    long long z;
    for (auto it : ma)
      if (mx < it.second) z = it.first, mx = max(mx, it.second);
    cout << mx << endl;
    for (i = 0; i < mx; i++) cout << z << " ";
    return 0;
  }
  vector<long long> v1, v2;
  for (i = ml; i <= mr; i++) {
    for (j = 0; j < ma[i] - 1; j++) v1.push_back(i);
    v2.push_back(i);
  }
  for (auto it : v1) cout << it << " ";
  for (i = v2.size() - 1; i >= 0; i--) cout << v2[i] << " ";
}
