#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int cnt[N + 5];
int main() {
  ios::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]++;
  }
  int ans = 0;
  int sum = 0;
  int idx = -1;
  for (int i = 1; i <= N; ++i) {
    if (cnt[i] == 0) {
      sum = 0;
      continue;
    }
    sum += cnt[i];
    if (ans < sum) {
      ans = sum;
      idx = i;
    }
    if (cnt[i] == 1 && sum != cnt[i]) {
      sum = cnt[i];
    }
  }
  cout << ans << endl;
  for (int i = 0; i < cnt[idx]; ++i) cout << idx << " ";
  int end = -1;
  for (int i = idx - 1; i >= 0; --i) {
    end = i;
    for (int j = 0; j < cnt[i] - 1; ++j) {
      cout << i << " ";
    }
    if (cnt[i] <= 1) break;
  }
  if (cnt[end] == 0) end++;
  for (int i = end; i < idx; ++i) {
    cout << i << " ";
  }
  cout << endl;
}
