#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N];
vector<int> q[N];
int l[N], r[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
  int cnt = 0;
  int mx = 0, id = 0;
  for (int i = 1; i <= n; i++) {
    int len = q[cnt].size();
    if (len) {
      int f = 0;
      if (len >= 2) {
        if (q[cnt][len - 2] + 1 >= a[i]) f = 1;
      } else {
        if (q[cnt][0] + 1 >= a[i]) f = 1;
      }
      if (!f) {
        cnt++;
        if (a[i - 1] + 1 >= a[i]) q[cnt].push_back(a[i - 1]);
      }
    }
    q[cnt].push_back(a[i]);
    if (q[cnt].size() > mx) {
      mx = q[cnt].size();
      id = cnt;
    }
  }
  printf("%d\n", mx);
  for (int i = 0; i < q[id].size(); i++) {
    if (i % 2 == 0)
      l[++l[0]] = q[id][i];
    else
      r[++r[0]] = q[id][i];
  }
  for (int i = l[0]; i >= 1; i--) printf("%d ", l[i]);
  for (int i = 1; i <= r[0]; i++) printf("%d ", r[i]);
  return 0;
}
