#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<int> h;
int dp[200001];
int cnt[200001];
set<int> s;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    cnt[a]++;
    s.insert(a);
  }
  int last = -2;
  int total = 0;
  int mx1 = 0, mx2 = 0;
  for (int i : s) {
    if (i - last == 1) {
      dp[i] = cnt[i - 1] > 1 ? dp[i - 1] : i - 1;
      total = cnt[i - 1] > 1 ? total : cnt[i - 1];
    } else {
      dp[i] = i;
      total = 0;
    }
    total += cnt[i];
    if (total > mx1) {
      mx1 = total;
      mx2 = i;
    }
    last = i;
  }
  cout << mx1 << endl;
  for (int i = dp[mx2]; i <= mx2; ++i) {
    for (int j = 0; j < cnt[i] - 1; ++j) {
      cout << i << " ";
    }
  }
  for (int i = mx2; i >= dp[mx2]; --i) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
