#include <bits/stdc++.h>
using namespace std;
namespace wode {
template <typename T>
inline void read(T &x) {
  static char ch;
  bool f = 1;
  for (x = 0, ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') f = 0;
  for (; isdigit(ch); x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar())
    ;
  x = f ? x : -x;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void print(T x, char ap) {
  print(x);
  if (ap) putchar(ap);
}
template <typename T>
inline T max(T x, T y) {
  return x < y ? y : x;
}
template <typename T>
inline T min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = x < y ? y : x;
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = x < y ? x : y;
}
}  // namespace wode
using wode::chkmax;
using wode::chkmin;
using wode::print;
using wode::read;
deque<int> q;
int n, tong[200001], f[200001][2], x, maxx, p, tot;
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i) read(x), ++tong[x], chkmax(maxx, x);
  for (register int i = 1; i <= maxx; ++i)
    if (tong[i] > 1)
      f[i][1] = tong[i];
    else if (tong[i])
      f[i][0] = 1;
  for (register int i = 1; i <= maxx; ++i)
    if (tong[i]) {
      if (tong[i - 1] == 1)
        chkmax(f[i][1], f[i - 1][0] + tong[i]);
      else if (tong[i - 1] > 1)
        chkmax(f[i][1], f[i - 1][1] + tong[i]);
    }
  for (register int i = 1; i <= maxx; ++i) {
    if (f[i][1] > tot) tot = f[i][1], p = i;
    if (f[i][0] > tot) tot = f[i][0], p = i;
  }
  for (register int i = 1; i <= tong[p]; ++i) q.push_back(p);
  --p;
  while (tong[p] > 1) {
    for (register int i = 1; i <= tong[p] >> 1; ++i) q.push_front(p);
    for (register int i = 1; i <= tong[p] - (tong[p] >> 1); ++i) q.push_back(p);
    --p;
  }
  if (tong[p]) q.push_front(p);
  print(q.size(), '\n');
  for (deque<int>::iterator it = q.begin(); it != q.end(); ++it)
    print(*it, ' ');
  puts("");
  return 0;
}
