#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
const long long INF = 1e9;
const long long MOD = 1000000007;
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int arr[N];
  memset(arr, 0, sizeof(arr));
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    arr[x]++;
  }
  int st = 0;
  int p = 0;
  int mm = 0;
  int pre = 0;
  int mst = 0;
  int mend = 0;
  for (int i = 1; i < N; i++) {
    if (arr[i] > 0 && p == 0) {
      pre = arr[i];
      st = i;
      p++;
    } else if (p > 0) {
      pre += arr[i];
      if (arr[i] == 0) {
        if (pre > mm) {
          mst = st;
          mend = i - 1;
          mm = pre;
        }
        pre = 0;
        p = 0;
      }
      if (arr[i] == 1) {
        if (pre > mm) {
          mst = st;
          mend = i;
          mm = pre;
        }
        pre = 1;
        st = i;
      }
    }
  }
  cout << mm << endl;
  for (int i = mst; i <= mend; i++) cout << i << ' ';
  for (int i = mend; i >= mst; i--) {
    for (int j = 0; j < arr[i] - 1; j++) cout << i << ' ';
  }
}
