#include <bits/stdc++.h>
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
using namespace std;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
void accelerate() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  int n;
  cin >> n;
  vector<int> cnt(200001);
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    cnt[tmp]++;
  }
  long long ans = 0;
  long long sum = 0;
  int sta = -1;
  int l, r;
  l = r = -1;
  for (int i = 0; i < 200001; ++i) {
    if (cnt[i] == 0) {
      if (ans < sum) {
        ans = sum;
      }
      sum = 0;
      sta = -1;
    } else if (cnt[i] == 1) {
      sum += cnt[i];
      if (sta == -1) {
        sta = i;
      }
      if (ans < sum) {
        ans = sum;
        l = sta;
        r = i;
      }
      sta = i;
      sum = cnt[i];
    } else {
      sum += cnt[i];
      if (sta == -1) {
        sta = i;
      }
      if (ans < sum) {
        ans = sum;
        l = sta;
        r = i;
      }
    }
  }
  cout << ans << endl;
  for (int i = l; i < r + 1; ++i) {
    if (i == l) {
      for (int k = 0; k < cnt[i]; ++k) {
        cout << i << " ";
      }
    } else if (i == r) {
      for (int k = 0; k < cnt[i]; ++k) {
        cout << i << " ";
      }
    } else {
      for (int k = 0; k < cnt[i] - 1; ++k) {
        cout << i << " ";
      }
    }
  }
  for (int i = r - 1; i > l; --i) {
    cout << i << " ";
  }
  cout << endl;
}
