#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
int a[N], c[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), c[a[i]]++;
  int ans = 0;
  int l, r;
  int ansl, ansr;
  int sum = 0;
  for (int i = 1; i < N; i++) {
    if (c[i] >= 1 && sum == 0) {
      l = i;
      sum += c[i];
    } else if (c[i] > 1) {
      sum += c[i];
    } else if (sum > 0) {
      if (c[i] == 1)
        sum++, r = i;
      else
        r = i - 1;
      if (sum > ans) {
        ans = sum;
        ansl = l;
        ansr = r;
      }
      sum = 0;
      if (c[i] == 1) {
        sum++;
        l = i;
      }
    }
  }
  cout << ans << '\n';
  if (c[ansl] == 1) cout << ansl << ' ', ansl++;
  for (int i = ansl; i <= ansr; i++) {
    for (int j = 1; j < c[i]; j++) {
      printf("%d ", i);
    }
  }
  for (int i = ansr; i >= ansl; i--) {
    printf("%d ", i);
  }
  return 0;
}
