#include <bits/stdc++.h>
using namespace std;
int n;
const int m = 200001;
int a[200005];
int tree[200005 * 4];
void init(int node, int b, int e) {
  if (b == e) {
    tree[node] = a[b];
    return;
  }
  int Left = node * 2;
  int Right = node * 2 + 1;
  int mid = (b + e) / 2;
  init(Left, b, mid);
  init(Right, mid + 1, e);
  tree[node] = min(tree[Left], tree[Right]);
}
int query(int node, int b, int e, int i, int j) {
  if (i > e || j < b) return INT_MAX;
  if (b >= i && e <= j) return tree[node];
  int Left = node * 2;
  int Right = node * 2 + 1;
  int mid = (b + e) / 2;
  int p1 = query(Left, b, mid, i, j);
  int p2 = query(Right, mid + 1, e, i, j);
  return min(p1, p2);
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  };
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x]++;
  }
  init(1, 1, m);
  for (int i = 1; i <= m; i++) a[i] += a[i - 1];
  int mx = 0;
  int st, en;
  for (int i = 1; i < m; i++) {
    if (a[i] - a[i - 1] == 0) continue;
    int lo = i + 1, hi = m;
    if (a[lo] - a[i] == 0) {
      if (a[i] - a[i - 1] > mx) {
        mx = a[i] - a[i - 1];
        st = i, en = i;
      }
      continue;
    }
    while (lo < hi) {
      int mid = (hi + lo + 1) / 2;
      if (query(1, 1, m, i + 1, mid) >= 2)
        lo = mid;
      else
        hi = mid - 1;
    }
    if (a[lo + 1] - a[lo] == 1 && a[lo] - a[lo - 1] > 1) lo++;
    if (a[lo] - a[i - 1] > mx) {
      mx = a[lo] - a[i - 1];
      st = i, en = lo;
    }
  }
  cout << mx << endl;
  for (int i = st; i <= en; i++) {
    int p = a[i] - a[i - 1];
    while (p != 1) {
      cout << i << ' ';
      p--;
    }
  }
  for (int i = en; i >= st; i--) cout << i << ' ';
  cout << endl;
}
