#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int maxn = 2e5 + 5;
int a[maxn], num[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int q = 1; q <= n; q++) {
    scanf("%d", &a[q]);
    num[a[q]]++;
  }
  sort(a + 1, a + 1 + n);
  n = unique(a + 1, a + 1 + n) - a - 1;
  int ans = 0, t = 0, l = 0, r = 0, ansr = 0;
  for (int q = 1; q <= n; q++) {
    t = num[a[q]];
    r = q;
    for (int w = q + 1; w <= n; w++) {
      if (abs(a[w] - a[w - 1]) <= 1) {
        r = w;
        t += num[a[w]];
        if (num[a[w]] >= 2)
          continue;
        else
          break;
      } else
        break;
    }
    if (ans < t) {
      ans = t;
      l = q;
      ansr = r;
    }
    if (r == q)
      continue;
    else
      q = r - 1;
  }
  r = ansr;
  printf("%d\n", ans);
  printf("%d", a[l]);
  num[a[l]]--;
  for (int q = l + 1; q <= r; q++) {
    printf(" %d", a[q]);
    num[a[q]]--;
  }
  for (int q = r; q >= l; q--) {
    for (int w = 0; w < num[a[q]]; w++) {
      printf(" %d", a[q]);
    }
  }
  return 0;
}
