#include <bits/stdc++.h>
using namespace std;
int n, frec[200000 + 10], l[200000 + 10], r[200000 + 10], sp[200000 + 10], ans,
    p;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    frec[x]++;
  }
  int nr = 1;
  for (int i = 1; i <= 200000; i++) {
    sp[i] = frec[i] + sp[i - 1];
    if (frec[i] < 2) nr = i;
    l[i] = nr;
  }
  nr = 200000 + 1;
  sp[200000 + 1] = sp[200000];
  for (int i = 200000; i; i--) {
    r[i] = nr;
    if (frec[i] < 2) nr = i;
  }
  for (int i = 1; i <= 200000; i++) {
    int val = sp[r[i]] - sp[l[i] - 1];
    if (val > ans) ans = val, p = i;
  }
  cout << ans << '\n';
  for (int i = p; i >= l[p]; i--)
    if (frec[i]) frec[i]--, cout << i << ' ';
  for (int i = l[p]; i <= p; i++)
    while (frec[i]) frec[i]--, cout << i << ' ';
  for (int i = p + 1; i <= r[p]; i++)
    if (frec[i]) frec[i]--, cout << i << ' ';
  for (int i = r[p]; i >= p + 1; i--)
    while (frec[i]) frec[i]--, cout << i << ' ';
  cout << '\n';
  return 0;
}
