#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int arr[200009], vis[200009];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", arr + i);
  sort(arr + 1, arr + n + 1);
  for (int i = 1; i + 2 <= n; i++) vis[i] = (arr[i + 2] - arr[i] <= 1);
  int ans = 1;
  pair<int, int> who = make_pair(1, 1);
  for (int i = 1; i < n; i++)
    if (arr[i + 1] - arr[i] <= 1) ans = 2, who = make_pair(i, i + 1);
  if (ans == 2) {
    int last = 1, cnt = 0;
    for (int i = 1; i < n; i++)
      if (vis[i])
        cnt++;
      else {
        if (umax(ans, cnt + 2)) who = make_pair(last, i + 1);
        cnt = 0;
        last = i + 1;
      }
  }
  cout << ans << endl;
  if ((who.second - who.first) & 1) {
    for (int i = who.first; i < who.second; i += 2) cout << arr[i] << " ";
    for (int i = who.second; i > who.first; i -= 2) cout << arr[i] << " ";
  } else {
    for (int i = who.first; i <= who.second; i += 2) cout << arr[i] << " ";
    who.second--;
    for (int i = who.second; i > who.first; i -= 2) cout << arr[i] << " ";
  }
  return 0;
}
