#include <bits/stdc++.h>
using namespace std;
long long n, m, c, p, k, mx = -10000000000000000, mn = 10000000000000000, ans;
double db, xx, yy;
long long a[100001], b[100001], d[100005], x, y, z, l, r;
char ch;
string second, t, sr[10001];
int used[100001];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], used[a[i]]++, m = max(m, a[i]);
  x = 1;
  for (int i = 1; i <= n; i++) {
    if (!c)
      while (!used[x] && x <= m) x++;
    else
      while (!used[x] && x >= 1) x--;
    if (x > m) {
      c = 1;
      x = m - 1;
      continue;
    }
    if (x == m) {
      c = 1;
      d[r++] = x;
      used[x]--;
      x = m - 1;
      continue;
    }
    if (!x) break;
    d[r++] = x, used[x]--;
    if (c)
      x--;
    else
      x++;
  }
  cout << r << endl;
  for (int i = 0; i < r; i++) cout << d[i] << " ";
  cout << endl;
  return 0;
}
