#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  map<int, int> mp;
  vector<int> vec;
  for (int i = 1; i <= n; i++) {
    int height;
    cin >> height;
    mp[height] += 1;
    if (mp[height] == 1) {
      vec.push_back(height);
    }
  }
  sort(vec.begin(), vec.end());
  int mx_size = 0, shortest, tallest;
  int size = mp[vec[0]], shorter = vec[0], taller = vec[0];
  int m = vec.size();
  for (int index = 1; index < m; index++) {
    if (vec[index] == vec[index - 1] + 1) {
      size += mp[vec[index]];
      taller = vec[index];
      if (mp[vec[index]] == 1) {
        if (mx_size < size) {
          mx_size = size;
          shortest = shorter;
          tallest = taller;
        }
        size = 1;
        shorter = vec[index];
        taller = vec[index];
      }
    } else {
      if (mx_size < size) {
        mx_size = size;
        shortest = shorter;
        tallest = taller;
      }
      size = mp[vec[index]];
      shorter = vec[index];
      taller = vec[index];
    }
  }
  if (mx_size < size) {
    mx_size = size;
    shortest = shorter;
    tallest = taller;
  }
  list<int> final1;
  list<int> final2;
  for (int height = shortest; height <= tallest; height++) {
    int counter = mp[height];
    if (counter == 1) {
      final1.push_back(height);
    } else {
      final2.push_front(height);
      counter--;
      while (counter--) {
        final1.push_back(height);
      }
    }
  }
  cout << mx_size << endl;
  for (auto height : final1) {
    cout << height << " ";
  }
  for (auto height : final2) {
    cout << height << " ";
  }
}
