#include <bits/stdc++.h>
const double eps = (1e-9);
using namespace std;
int dcmp(long double a, long double b) {
  return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;
}
int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }
int setBit1(int num, int idx) { return num | (1 << idx); }
long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }
long long flipBit(int num, int idx) { return num ^ (1 << idx); }
void FS() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const int N = 200009;
int vis[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int no;
    cin >> no;
    vis[no]++;
  }
  int mx = 0;
  pair<int, int> p;
  for (int i = 1; i <= 200000;) {
    int cnt = 0;
    int str = -1, en = -1, ti = i;
    while (1) {
      if (vis[ti] >= 2) {
        if (str == -1) str = ti;
        en = ti;
        cnt += vis[ti];
        ti++;
      } else if (vis[ti] == 1) {
        if (str == -1) str = ti;
        en = ti;
        cnt += vis[ti];
        ti++;
        break;
      } else {
        ti++;
        break;
      }
    }
    if (i - 1 >= 1 && vis[i - 1]) cnt += vis[i - 1], str = i - 1;
    if (cnt > mx) {
      mx = cnt;
      p = make_pair(str, en);
    }
    i = ti;
  }
  cout << mx << endl;
  for (int i = p.first; i <= p.second; i++) {
    while (vis[i] > 1) {
      cout << i << " ";
      vis[i]--;
    }
  }
  for (int i = p.second; i >= p.first; i--) {
    while (vis[i]) {
      cout << i << " ";
      vis[i]--;
    }
  }
}
