#include <bits/stdc++.h>
using namespace std;
const int sz = 200001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(sz, 0);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[tmp]++;
  }
  int ans = 0;
  int x = -1;
  int y = -1;
  for (int i = 1; i < sz; i++) {
    if (a[i] > 0) {
      int tmp = a[i];
      int j = i + 1;
      while (a[j] > 1) {
        tmp += a[j];
        j++;
      }
      tmp += a[j];
      if (tmp > ans) {
        ans = tmp;
        x = i;
        y = j;
      }
      i = j - 1;
    }
  }
  if (!a[x]) x++;
  if (!a[y]) y--;
  cout << ans << "\n";
  for (int i = x; i <= y; i++) {
    cout << i << " ";
    a[i]--;
  }
  for (int i = y; i >= x; i--) {
    while (a[i] > 0) {
      a[i]--;
      cout << i << " ";
    }
  }
  return 0;
}
