#include <bits/stdc++.h>
using namespace std;
const int MAXH = 2e5;
int n, a[MAXH], num[MAXH + 10];
int sumAns = 0;
pair<int, int> rangeAns;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    num[a[i]]++;
  }
  for (int i = 1; i <= MAXH; ++i) {
    if (num[i] > 0) {
      int j = i + 1;
      int sum = num[i];
      while (j <= MAXH && num[j] >= 2) {
        sum += num[j];
        ++j;
      }
      if (num[j] == 1) {
        sum += num[j];
        ++j;
      }
      if (sum > sumAns) {
        sumAns = sum;
        rangeAns = pair<int, int>(i, j - 1);
      }
      if (i + 1 == j) {
        ++j;
      }
      i = j - 2;
    }
  }
  printf("%d\n", sumAns);
  for (int i = 0; i < num[rangeAns.first]; ++i) printf("%d ", rangeAns.first);
  if (rangeAns.first != rangeAns.second) {
    for (int i = rangeAns.first + 1; i < rangeAns.second; ++i) printf("%d ", i);
    for (int i = 0; i < num[rangeAns.second]; ++i)
      printf("%d ", rangeAns.second);
    for (int i = rangeAns.second - 1; i > rangeAns.first; --i)
      for (int j = 0; j < num[i] - 1; ++j) printf("%d ", i);
  }
  printf("\n");
}
