#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  map<int, int> mp;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int add;
    cin >> add;
    v.push_back(add);
    mp[add]++;
  }
  int mxst = 0, mxed = 0, mx = 0;
  int now = 1;
  while (now <= 200000) {
    if (mp.find(now) == mp.end()) {
      now++;
      continue;
    }
    int st = now;
    int ed = now;
    int cnt = 0;
    while (1) {
      if (mp.find(ed) == mp.end()) {
        ed--;
        break;
      } else {
        cnt += mp[ed];
        if (mp[ed] == 1 && ed != st) {
          break;
        } else {
          ed++;
        }
      }
    }
    if (cnt > mx) {
      mx = cnt;
      mxst = st;
      mxed = ed;
    }
    if (mp[ed] == 1 && mp.find(ed + 1) != mp.end()) {
      now = ed;
    } else {
      now = ed + 1;
    }
  }
  cout << mx << endl;
  for (int i = mxst; i <= mxed; i++) {
    cout << i << ' ';
    mp[i]--;
  }
  for (int i = mxed; i >= mxst; i--) {
    while (mp[i] != 0) {
      cout << i << ' ';
      mp[i]--;
    }
  }
}
