#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int c[N], n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    c[x]++;
  }
  bool f = 0;
  int ans = 0, l = 0, r = 0, tmp = 0, tl = 0;
  for (int i = 1; i < N; i++)
    if (c[i]) ans = c[i], l = i, r = i;
  for (int i = 1; i < N; i++)
    if (c[i] && c[i + 1]) ans = c[i] + c[i + 1], l = i, r = i + 1;
  for (int i = 1; i < N; i++) {
    if (c[i] >= 2) {
      tmp += c[i];
      f = 1;
    } else if (f) {
      f = 0;
      tmp += c[i];
      if (tmp > ans) {
        ans = tmp;
        l = tl;
        r = i;
      }
    }
    if (!f) {
      tmp = c[i];
      tl = i;
    }
  }
  cout << ans << endl;
  for (int i = l; i <= r; i++)
    for (int k = 1; k <= (c[i] + 1) / 2; k++) {
      cout << i << " ";
    }
  for (int i = r; i >= l; i--)
    for (int k = 1; k <= c[i] / 2; k++) {
      cout << i << " ";
    }
  cout << endl;
}
