#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> m;
  int lk = 1;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    m[v[i]]++;
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  int l = 0, r = 1;
  vector<int> si(int(v.size()) + 1);
  si[0] = m[v[0]];
  for (int i = 1; i < int(v.size()); i++) {
    si[i] = si[i - 1] + m[v[i]];
  }
  int ma = 1;
  int diff;
  int l1, r1;
  while (r < int(v.size())) {
    if (v[r] - v[r - 1] <= 1) {
      if (r - l >= 2) {
        if (m[v[r - 1]] > 1) {
          if (l == 0) {
            diff = si[r];
          } else {
            diff = si[r] - si[l - 1];
          }
          if (ma < diff) {
            ma = diff;
            l1 = l;
            r1 = r;
          }
          r = r + 1;
        } else {
          l = r - 1;
        }
      } else {
        if (l == 0) {
          diff = si[r];
        } else {
          diff = si[r] - si[l - 1];
        }
        if (ma < diff) {
          ma = diff;
          l1 = l;
          r1 = r;
        }
        r = r + 1;
      }
    } else {
      l = r;
      r = r + 1;
    }
  }
  int his;
  if (ma == 1) {
    for (int i = 0; i < int(v.size()); i++) {
      if (lk <= m[v[i]]) {
        lk = m[v[i]];
        his = i;
      }
    }
    cout << lk << endl;
    for (int i = 1; i <= m[v[his]]; i++) {
      cout << v[his] << " ";
    }
  } else {
    cout << ma << endl;
    for (int i = l1; i <= r1; i++) {
      cout << v[i] << " ";
      m[v[i]]--;
    }
    for (int i = r1; i >= l1; i--) {
      for (int j = 1; j <= m[v[i]]; j++) {
        cout << v[i] << " ";
      }
    }
  }
}
