#include <bits/stdc++.h>
using namespace std;
int ara[200005], fre[200005];
vector<int> v, ans, temp1, store;
int main() {
  int i, j, k, n, cnt = 0, mx = 0;
  scanf("%d", &(n));
  for (i = 0; i < n; i++) {
    scanf("%d", &(ara[i]));
    if (fre[ara[i]] == 0) v.push_back(ara[i]);
    fre[ara[i]]++;
  }
  sort(v.begin(), v.end());
  bool fg = 0;
  for (i = 1; i <= 200003; i++) {
    if (fre[i] == 0 || fg == 1) {
      if (cnt >= mx) {
        mx = cnt;
        store = temp1;
      }
      if (fg == 1) i -= 1;
      fg = 0;
      cnt = 0;
      temp1.clear();
    }
    if (fg == 0 && fre[i] >= 2) {
      cnt += fre[i];
      temp1.push_back(i);
    } else if (fg == 0 && fre[i] == 1 && cnt == 0) {
      cnt += fre[i];
      temp1.push_back(i);
    } else if (fg == 0 && fre[i] == 1 && cnt > 0) {
      cnt += fre[i];
      temp1.push_back(i);
      fg = 1;
    }
  }
  cout << mx << endl;
  for (i = 0; i < store.size(); i++) cout << store[i] << " ";
  for (i = store.size() - 1; i >= 0; i--) {
    fre[store[i]]--;
    while (fre[store[i]]) {
      printf("%d ", store[i]);
      fre[store[i]]--;
    }
  }
  return 0;
}
