#include <bits/stdc++.h>
using namespace std;
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
template <class T>
istream& operator>>(istream& in, vector<vector<T>>& v) {
  for (int i = 0; i < v.size(); ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      in >> v[i][j];
    }
  }
  return in;
}
template <char d = ' ', class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto& e : v) {
    out << e << d;
  }
  return out;
}
template <char d = ' ', class T>
ostream& operator<<(ostream& out, vector<vector<T>>& v) {
  for (int i = 0; i < v.size(); ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << d;
    }
    out << '\n';
  }
  return out;
}
template <char d = ' ', class T>
ostream& operator<<(ostream& out, set<T>& v) {
  for (auto& e : v) {
    out << e << d;
  }
  return out;
}
template <class T>
bool cmpup(T& a, T b) {
  return a > b;
}
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> kol(200100, 0);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    kol[a]++;
  }
  int maxc = 0, st = -1, fn = -1;
  bool lo = 0;
  int curc = 0, cst = -1;
  for (int i = 0; i < 200100; ++i) {
    if (lo) {
      curc += kol[i];
      if (kol[i] < 2) {
        if (curc > maxc) {
          maxc = curc;
          st = cst;
          fn = i - 1;
          if (kol[i] == 1) fn = i;
        }
        lo = 0;
        if (kol[i] == 1) {
          cst = i;
          curc = 1;
          lo = 1;
        }
      }
    } else {
      if (kol[i] > 0) {
        lo = 1;
        cst = i;
        curc = kol[i];
      }
    }
  }
  if (lo && curc > maxc) {
    maxc = curc;
    st = cst;
    fn = n - 1;
  }
  cout << maxc << '\n';
  for (int i = st; i <= fn; ++i) cout << i << ' ';
  for (int i = fn; i >= st; --i)
    if (kol[i] > 1)
      for (int j = 1; j < kol[i]; ++j) cout << i << ' ';
  return 0;
}
