#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
  if (a > b)
    return a;
  else
    return b;
}
long long int min(long long int a, long long int b) {
  if (a < b)
    return a;
  else
    return b;
}
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t, n, i, j, k, u, v, m, x, y, z;
  cin >> n;
  long long int arr[n];
  set<long long int> s;
  map<long long int, long long int> mpp;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    s.insert(arr[i]);
    mpp[arr[i]]++;
  }
  long long int ans = 1, mini = arr[0], maxi = arr[0], count = 1;
  while (s.size() != 0) {
    long long int val = *(s.begin());
    s.erase(val);
    long long int c2 = mpp[val];
    long long int mini2 = val, maxi2 = val;
    val++;
    while (!s.empty()) {
      if (mpp[val] <= 1) break;
      s.erase(val);
      c2 += mpp[val];
      maxi2 = val;
      val++;
    }
    if (mpp[val] == 1) {
      c2++;
      maxi2 = val;
    }
    if (c2 > ans) {
      ans = c2;
      mini = mini2;
      maxi = maxi2;
    }
  }
  cout << ans << "\n";
  for (i = mini; i <= maxi; i++) {
    while (mpp[i] > 1) {
      cout << i << " ";
      mpp[i]--;
    }
  }
  for (i = maxi; i >= mini; i--) {
    cout << i << " ";
  }
}
