#include <bits/stdc++.h>
using namespace std;
const int nm = 1e5 + 3;
const long long mod = 1e18;
int n, m;
int a[5010];
int ans[nm];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  while (cin >> n) {
    int mm = 0;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      a[x]++;
      mm = max(mm, x);
    }
    int tot = 0;
    for (int i = 1; i <= 5000; i++) {
      if (a[i] > 1) {
        ans[tot++] = i;
      }
    }
    if (tot == 0)
      ans[tot++] = mm;
    else if (ans[tot - 1] != mm) {
      ans[tot++] = mm;
    }
    for (int i = ans[tot - 1] - 1; i > 0; i--) {
      if (a[i] > 0) {
        ans[tot++] = i;
      }
    }
    cout << tot << endl;
    for (int i = 0; i < tot; i++) cout << ans[i] << (i < tot - 1 ? ' ' : '\n');
  }
  return 0;
}
