#include <bits/stdc++.h>
using namespace std;
const int dydis = 2e5 + 10;
int cnt[dydis] = {0};
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  pair<int, pair<int, int> > ans = {-1, {-1, -1}};
  for (int i = 1; i < dydis; i++) {
    if (cnt[i] == 1) {
      ans = max(ans, {1, {i, i}});
      if (cnt[i + 1] == 1) {
        ans = max(ans, {2, {i, i + 1}});
      }
    }
    if (cnt[i] <= 1) continue;
    int sm = 0;
    for (int j = i; j < dydis; j++) {
      if (cnt[j] <= 1) {
        if (cnt[i - 1] == 1) {
          ans = max(ans, {sm + 1, {i - 1, j - 1}});
        }
        if (cnt[j] == 1) {
          ans = max(ans, {sm + 1, {j, i}});
        }
        if (cnt[i - 1] == 1 && cnt[j] == 1 && cnt[j - 1] >= 2) {
          ans = max(ans, {sm + 2, {i - 1, j}});
        }
        if (i != 1 && cnt[i - 1] == 1 && cnt[j] == 1 && cnt[i] >= 2) {
          ans = max(ans, {sm + 2, {j, i - 1}});
        }
        ans = max(ans, {sm, {i, j - 1}});
        i = j - 1;
        break;
      } else {
        sm += cnt[j];
      }
    }
  }
  vector<int> an;
  int l = ans.second.first;
  int r = ans.second.second;
  if (l <= r) {
    for (int i = l; i <= r; i++) {
      cnt[i]--;
      an.push_back(i);
    }
    for (int i = r; i >= l; i--) {
      while (cnt[i]) {
        cnt[i]--;
        an.push_back(i);
      }
    }
  } else {
    swap(l, r);
    for (int i = r; i >= l; i--) {
      cnt[i]--;
      an.push_back(i);
    }
    for (int i = l; i <= r; i++) {
      while (cnt[i]) {
        cnt[i]--;
        an.push_back(i);
      }
    }
  }
  cout << an.size() << "\n";
  for (auto x : an) cout << x << " ";
  return 0;
}
