#include <bits/stdc++.h>
using namespace std;
int a, c[200010] = {}, ans = 0, sum[200010];
pair<int, int> p;
int main() {
  int i, n;
  cin >> n;
  for (i = 0; i < n; i++) {
    int a;
    cin >> a;
    c[a]++;
  }
  for (i = 1; i <= 200001; i++) {
    sum[i] = sum[i - 1] + c[i];
  }
  int x = 0;
  for (i = 1; i <= 200000; i++) {
    x = max(x, i);
    while (c[x + 1] >= 2) {
      x++;
    }
    if (ans < sum[x + 1] - sum[i - 1]) {
      p = {i, x + 1};
      ans = sum[x + 1] - sum[i - 1];
    }
  }
  cout << ans << endl;
  int l = p.first, r = p.second, j;
  for (i = l; i <= r; i++) {
    if (c[i]) {
      cout << i << " ";
      c[i]--;
    }
  }
  for (i = r; i >= l; i--) {
    for (j = 0; j < c[i]; j++) {
      cout << i << " ";
    }
  }
  cout << endl;
}
