#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int a[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[x]++;
  }
  int sum = 0, flag = 0, t = 0, pos1, pos2, t1 = 0, t2;
  for (int i = 0; i < maxn; i++) {
    if (a[i] == 0) {
      if (flag && sum < t) {
        t2 = i - 1;
        sum = t;
        pos1 = t1;
        pos2 = t2;
      }
      t = 0;
      t1 = i + 1;
      flag = 0;
    } else {
      t += a[i];
      if (flag && a[i] == 1) {
        t2 = i;
        if (sum < t) {
          sum = t;
          pos1 = t1;
          pos2 = t2;
        }
        t1 = i;
        t = 1;
      }
      flag = 1;
    }
  }
  cout << sum << endl;
  cout << pos1;
  for (int i = pos1 + 1; i <= pos2; i++) cout << ' ' << i;
  for (int i = pos2; i >= pos1; i--) {
    for (int j = 0; j < a[i] - 1; j++) cout << ' ' << i;
  }
  cout << endl;
  return 0;
}
