#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n;
int a[N];
int cnt[N];
int dp[N];
int ans = 0, start = 0;
vector<int> top;
vector<int> bottom;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 2e5; i >= 1; i--) {
    dp[i] = cnt[i];
    if (cnt[i + 1] == 1) {
      dp[i] += 1;
    }
    if (cnt[i + 1] > 1) {
      dp[i] += dp[i + 1];
    }
    if (dp[i] > ans) {
      ans = dp[i];
      start = i;
    }
  }
  for (int i = start;; i++) {
    if (cnt[i] == 0) break;
    if (cnt[i] == 1) {
      top.push_back(i);
      if (i != start) break;
    }
    if (cnt[i] > 1) {
      top.push_back(i);
      for (int j = 0; j < cnt[i] - 1; j++) bottom.push_back(i);
    }
  }
  reverse(bottom.begin(), bottom.end());
  cout << ans << endl;
  for (int h : top) cout << h << " ";
  for (int h : bottom) cout << h << " ";
  cout << endl;
  return 0;
}
