#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
int a[maxn];
template <class T>
inline bool read(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
inline void out(int x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  int mx = 0;
  int n;
  read(n);
  int pp = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int b;
    read(b);
    a[b]++;
    pp = max(pp, b);
  }
  vector<pair<int, int> > v;
  vector<pair<int, int> > p;
  if (a[1]) v.push_back({1, a[1]});
  mx = ans = a[1];
  p = v;
  for (int i = 2; i <= pp; i++) {
    if (a[i] == 0 && mx == 0)
      continue;
    else if (a[i] == 0) {
      if (mx > ans) {
        ans = mx;
        p = v;
        v.clear();
        mx = 0;
      }
      v.clear();
      mx = 0;
    } else if (a[i] == 1) {
      if (mx) {
        v.push_back({i, 1});
        mx++;
        if (mx > ans) {
          ans = mx;
          p = v;
          v.clear();
          mx = 1;
          v.push_back({i, 1});
        }
        v.clear();
        mx = 1;
        v.push_back({i, 1});
      } else {
        mx = 1;
        v.push_back({i, 1});
      }
    } else {
      v.push_back({i, a[i]});
      mx += a[i];
    }
  }
  if (mx > ans) {
    ans = mx;
    p = v;
  }
  out(ans);
  putchar('\n');
  deque<int> dq;
  for (int i = 0; i < p.size(); i++) {
    for (int j = 0; j < p[i].second; j++) {
      if (j & 1)
        dq.push_back(p[i].first);
      else
        dq.push_front(p[i].first);
    }
  }
  for (auto i : dq) {
    out(i);
    putchar(' ');
  }
  return 0;
}
