#include <bits/stdc++.h>
using namespace std;
int counts[200009];
int pairs[200009];
int N;
int mas[200009];
int main() {
  cin >> N;
  memset(counts, 0, sizeof(counts));
  memset(pairs, 0, sizeof(pairs));
  for (int i = 0; i < N; i++) {
    cin >> mas[i];
    counts[mas[i]]++;
  }
  sort(mas, mas + N);
  for (int i = 0; i < N; i++) {
    if (counts[i] < 2)
      pairs[i] = 0;
    else {
      pairs[i] = 1;
      if (i > 0) pairs[i] += pairs[i - 1];
    }
  }
  int mn = -1;
  int mx = -1;
  int cnt = -1;
  for (int i = 0; i < 200009; i++)
    if (counts[i] > 0) {
      int up = i;
      int down = i;
      if (i > 0) down -= pairs[i - 1];
      if (down > 0 && counts[down - 1] > 0) down--;
      int c = upper_bound(mas, mas + N, up) - lower_bound(mas, mas + N, down);
      if (c > cnt) {
        cnt = c;
        mn = down;
        mx = up;
      }
    }
  vector<int> res;
  for (int i = mn; i <= mx; i++) {
    res.push_back(i);
    counts[i]--;
  }
  for (int i = mx; i >= mn; i--) {
    while (counts[i] > 0) {
      res.push_back(i);
      counts[i]--;
    }
  }
  cout << res.size() << "\n";
  for (int i = 0; i < res.size(); i++) {
    if (i > 0) cout << " ";
    cout << res[i];
  }
  cout << "\n";
  return 0;
}
