#include <bits/stdc++.h>
using namespace std;
int B[200002];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    B[a]++;
  }
  vector<int> ans;
  for (int i = 1; i <= 200000;) {
    if (ans.size() < 2 and B[i] > 0 and B[i + 1] > 0) {
      ans.clear();
      ans.push_back(i);
      ans.push_back(i + 1);
    }
    if (ans.size() < 1 and B[i] > 0) {
      ans.push_back(i);
    }
    if (B[i] < 2) {
      i++;
      continue;
    }
    int streak{}, j{i};
    while (B[i] >= 2) {
      streak += B[i];
      i++;
    }
    if (B[j - 1] > 0) {
      streak++;
      j--;
    }
    if (B[i] > 0) {
      streak++;
      i++;
    }
    if (streak > ans.size()) {
      ans.clear();
      for (int k = j; k < i; k++) ans.push_back(k);
      for (int k = i - 1; k >= j; k--)
        for (int l = 0; l < B[k] - 1; l++) ans.push_back(k);
    }
  }
  cout << ans.size() << '\n';
  for (auto e : ans) cout << e << ' ';
}
