#include <bits/stdc++.h>
using namespace std;
int n, a[200005], cnt[200005];
int l[200005], r[200005];
int sum[200005];
int ans[200005], tot = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), cnt[a[i]]++;
  for (int i = 1; i <= 200000; i++) sum[i] = sum[i - 1] + cnt[i];
  for (int i = 1; i <= 200000; i++) {
    if (cnt[i] == 1)
      l[i] = i;
    else if (cnt[i] >= 2) {
      if (cnt[l[i - 1]])
        l[i] = l[i - 1];
      else
        l[i] = i;
    } else
      l[i] = 0;
  }
  for (int i = 200000; i >= 1; i--) {
    if (cnt[i] == 1)
      r[i] = i;
    else if (cnt[i] >= 2) {
      if (cnt[r[i + 1]])
        r[i] = r[i + 1];
      else
        r[i] = i;
    } else
      r[i] = 0;
  }
  bool flag1 = false;
  int sta2;
  for (int i = 1; i < 200000; i++)
    if (cnt[i] && cnt[i + 1]) {
      flag1 = true;
      sta2 = i;
    }
  int sta, maxx = 0;
  for (int i = 1; i <= 200000; i++) {
    if (cnt[i] && sum[r[i]] - sum[l[i] - 1] > maxx) {
      maxx = sum[r[i]] - sum[l[i] - 1];
      sta = i;
    }
  }
  if (flag1 && maxx < 2) return printf("2\n%d %d\n", sta2, sta2 + 1), 0;
  for (int i = sta; i <= r[sta]; i++)
    for (int j = 1; j <= cnt[i] - 1; j++) ans[++tot] = i;
  for (int i = r[sta]; i >= l[sta]; i--) ans[++tot] = i;
  for (int i = l[sta]; i < sta; i++)
    for (int j = 1; j <= cnt[i] - 1; j++) ans[++tot] = i;
  printf("%d\n", tot);
  for (int i = 1; i <= tot; i++) printf("%d%c", ans[i], i == tot ? '\n' : ' ');
}
