#include <bits/stdc++.h>
using namespace std;
int n;
int ar[100010];
int br[5010];
int cr[10010];
int main() {
  cin >> n;
  int MAX = 0;
  int t, k;
  int count = 0;
  memset(ar, 0, 100010 * sizeof(int));
  memset(br, 0, 5010 * sizeof(int));
  memset(cr, 0, 10010 * sizeof(int));
  t = 0;
  k = 10009;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    if (MAX < ar[i]) MAX = ar[i];
    br[ar[i]]++;
  }
  br[MAX] = 1;
  for (int i = 0; i < 5010; i++) {
    if (br[i] == 1) {
      cr[k] = i;
      k--;
      count++;
    } else if (br[i] >= 2) {
      cr[t] = i;
      cr[k] = i;
      t++;
      k--;
      count = count + 2;
    }
  }
  cout << count << endl;
  for (int i = 0; i < 10010; i++) {
    if (cr[i] != 0) {
      cout << cr[i];
      if (i == 10009)
        cout << endl;
      else
        cout << " ";
    }
  }
  return 0;
}
