#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 1e5 + 5;
int a[maxn];
int main() {
  int n, ai, minl = maxn, maxr = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ai);
    a[ai]++;
    minl = min(minl, ai);
    maxr = max(maxr, ai);
  }
  long long ans = 0, sum = 0;
  int cnt = 0;
  int l, r, ansl, ansr;
  for (int i = minl; i <= maxr; i++) {
    if (sum == 0) l = i;
    if (a[i] == 0) {
      sum = 0;
      cnt = 0;
    } else if (a[i] == 1) {
      if (sum == 0)
        sum++;
      else {
        ansl = sum + 1 > ans ? l : ansl;
        ansr = sum + 1 > ans ? i : ansr;
        ans = max(ans, sum + 1);
        sum = 1;
        l = i;
      }
    } else
      sum += a[i];
    ansl = sum > ans ? l : ansl;
    ansr = sum > ans ? i : ansr;
    ans = max(ans, sum);
  }
  printf("%lld\n", ans);
  for (int i = ansl; i <= ansr; i++) {
    printf("%d ", i);
    a[i]--;
  }
  for (int i = ansr; i >= ansl; i--) {
    for (int j = 0; j < a[i]; j++) {
      printf("%d ", i);
    }
  }
  printf("\n");
  return 0;
}
