#include <bits/stdc++.h>
using namespace std;
constexpr int MAX_HEIGHT = 2 * 100 * 1000;
int a[MAX_HEIGHT];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int height;
    cin >> height;
    ++a[--height];
  }
  int max_idx;
  int max_sum = 0;
  int max_len;
  for (int i = 0; i < MAX_HEIGHT;) {
    while (i < MAX_HEIGHT && a[i] == 0) {
      ++i;
    }
    if (i == MAX_HEIGHT) {
      break;
    }
    int sum = a[i];
    int j = i + 1;
    while (j < MAX_HEIGHT && a[j] >= 2) {
      sum += a[j];
      ++j;
    }
    if (j < MAX_HEIGHT && a[j] == 1) {
      sum += a[j];
      ++j;
    }
    if (sum > max_sum) {
      max_len = j - i;
      max_idx = i;
      max_sum = sum;
    }
    if (a[j - 1] == 1 && i + 1 != j) {
      --j;
    }
    i = j;
  }
  vector<int> ans1, ans2;
  for (int i = max_idx; i < max_idx + max_len; ++i) {
    ans2.push_back(i + 1);
    --a[i];
    while (a[i] > 0) {
      ans1.push_back(i + 1);
      --a[i];
    }
  }
  cout << max_sum << '\n';
  for (int a1 : ans1) {
    cout << a1 << ' ';
  }
  for (auto it = ans2.rbegin(); it != ans2.rend(); ++it) {
    cout << *it << ' ';
  }
  cout << '\n';
}
