#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int dp[MAX], cnt[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  for (int i = 1; i < MAX; i++) {
    dp[i] = cnt[i];
    if (cnt[i - 1] > 1) dp[i] += dp[i - 1];
    if (cnt[i - 1] > 0) dp[i] = max(dp[i], cnt[i] + 1);
  }
  int x = max_element(dp, dp + MAX) - dp;
  cout << dp[x] << "\n";
  vector<int> ans(dp[x], 0);
  int l = 0, r = dp[x] - 1;
  while (l <= r) {
    if (cnt[x] & 1)
      ans[l++] = x;
    else
      ans[r--] = x;
    cnt[x]--;
    if (!cnt[x]) x--;
  }
  for (int y : ans) cout << y << " ";
  return 0;
}
