#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k, cnt[200005], val, l, r, ans;
vector<int> a, b;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> val;
    a.push_back(val);
    cnt[val]++;
  }
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
  for (int i = 0; i < a.size(); i++) {
    int j = i + 1, mx = cnt[a[i]];
    while (a[j] - a[j - 1] == 1 and cnt[a[j]] > 1) {
      mx += cnt[a[j]];
      j++;
    }
    int cr = j - 1;
    if (j < n && a[j] - a[j - 1] == 1) {
      mx += cnt[a[j]];
      cr = j;
    }
    if (mx > ans) {
      l = i;
      r = cr;
      ans = mx;
    }
    i = j - 1;
  }
  for (int i = l; i <= r; i++) {
    for (int j = 0; j < cnt[a[i]] / 2; j++) {
      b.push_back(a[i]);
    }
  }
  for (int i = r; i >= l; i--) {
    for (int j = 0; j < cnt[a[i]] - cnt[a[i]] / 2; j++) {
      b.push_back(a[i]);
    }
  }
  cout << b.size() << "\n";
  for (int i = 0; i < b.size(); i++) {
    cout << b[i] << " ";
  }
  return 0;
}
