#include <bits/stdc++.h>
using namespace std;
int a[200001];
int b[200001];
int c[200001];
int sum[200001];
int main() {
  int n, i, j;
  cin >> n;
  map<int, int> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  int p;
  map<int, int>::iterator it;
  for (it = m.begin(), p = 0; it != m.end(); ++it) {
    b[++p] = it->first;
  }
  int l = p;
  j = p;
  while (p >= 1) {
    c[p] = j;
    if (b[p] == 1) {
      j = p;
    }
    p--;
  }
  sum[1] = m[b[1]];
  int max = sum[1];
  j = 1;
  for (i = 2; i <= l; i++) {
    if (b[i] - b[i - 1] == 1) {
      if (m[b[i - 1]] == 1) {
        sum[i] = 1 + m[b[i]];
      } else {
        sum[i] = m[b[i]] + sum[i - 1];
      }
    } else {
      sum[i] = m[b[i]];
    }
    if (sum[i] > max) {
      max = sum[i];
      j = i;
    }
  }
  cout << max << endl;
  vector<int> v;
  while (max) {
    v.push_back(b[j]);
    max -= m[b[j]];
    j--;
  }
  for (i = v.size() - 1; i >= 0; i--) {
    cout << v[i] << " ";
  }
  for (i = 0; i < v.size(); i++) {
    for (j = 0; j < m[v[i]] - 1; j++) {
      cout << v[i] << " ";
    }
  }
  return 0;
}
