#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
inline bool mina(A &first, B second) {
  return (first > second) ? (first = second, 1) : 0;
}
template <class A, class B>
inline bool maxa(A &first, B second) {
  return (first < second) ? (first = second, 1) : 0;
}
const int MAXN = 2e5 + 5;
int N;
map<int, int> counter;
vector<pair<int, int> > people;
int num_from_left[MAXN];
int psum[MAXN];
int main() {
  int a;
  scanf("%d", &N);
  for (int i = 0; (i) < (N); ++(i)) {
    scanf("%d", &a);
    counter[a]++;
  }
  for (auto p : counter) {
    people.push_back(p);
  }
  N = ((int)(people).size());
  if (people[0].second >= 2) {
    num_from_left[0] = 1;
  }
  psum[0] = people[0].second;
  for (int i = 1; i < N; i++) {
    if (people[i].first - 1 == people[i - 1].first && people[i].second >= 2)
      num_from_left[i] = num_from_left[i - 1] + (people[i].second >= 2);
    else
      num_from_left[i] = people[i].second >= 2;
    psum[i] = psum[i - 1] + people[i].second;
  }
  int maxx = people[0].second;
  int start = 0;
  int end = 0;
  for (int i = 1; i < N; i++) {
    int total = people[i].second;
    int a, b;
    b = i;
    if (people[i].first - 1 == people[i - 1].first) {
      total += psum[i - 1] - psum[i - 1 - num_from_left[i - 1]];
      int front = i - 1 - num_from_left[i - 1];
      a = front + 1;
      if (front >= 0 && people[front + 1].first - 1 == people[front].first) {
        total += people[front].second;
        a--;
      }
    } else {
      a = i;
    }
    if (maxa(maxx, total)) {
      start = a;
      end = b;
    }
  }
  list<int> ans;
  for (int i = 0; (i) < (people[end].second); ++(i))
    ans.push_back(people[end].first);
  for (int i = end - 1; i > start; i--) {
    for (int j = 0; (j) < (people[i].second); ++(j)) {
      if (j & 1) {
        ans.push_back(people[i].first);
      } else {
        ans.push_front(people[i].first);
      }
    }
  }
  if (start != end) {
    for (int i = 0; (i) < (people[start].second); ++(i))
      ans.push_front(people[start].first);
  }
  assert(maxx == ((int)(ans).size()));
  printf("%d\n", maxx);
  for (auto first : ans) {
    printf("%d ", first);
  }
  printf("\n");
  return 0;
}
