#include <bits/stdc++.h>
using namespace std;
const int maxn = 234567;
int c[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    c[x]++;
  }
  int best = 1;
  for (int i = 1; i <= 200000;) {
    if (c[i] == 0)
      i++;
    else {
      int j = i + 1, sum = c[i];
      while (c[j] >= 2) {
        sum += c[j];
        j++;
      }
      sum += c[j];
      i = j;
      best = max(best, sum);
    }
  }
  printf("%d\n", best);
  for (int i = 1; i <= 200000;) {
    if (c[i] == 0)
      i++;
    else {
      int j = i + 1, sum = c[i];
      while (c[j] >= 2) {
        sum += c[j];
        j++;
      }
      sum += c[j];
      if (sum == best) {
        deque<int> r;
        for (int k = i; k <= j; k++) {
          for (int v = 0; v < c[k]; v++) {
            if (v & 1)
              r.push_front(k);
            else
              r.push_back(k);
          }
        }
        while (!r.empty()) {
          printf("%d ", r.back());
          r.pop_back();
        }
        return 0;
      }
      i = j;
    }
  }
  return 0;
}
