#include <bits/stdc++.h>
using namespace std;
int mark[5005];
int ans[100005];
int main() {
  int m;
  scanf("%d", &m);
  int x;
  for (int i = 0; i < m; i++) {
    scanf("%d", &x);
    mark[x]++;
  }
  int id = 0;
  for (int i = 1; i <= 5000; i++) {
    if (mark[i]) {
      ans[id++] = i;
      mark[i]--;
    }
  }
  int MAX = ans[id - 1];
  for (int i = 5000; i >= 1; i--) {
    if (mark[i] && i != MAX) {
      ans[id++] = i;
      mark[i]--;
    }
  }
  printf("%d\n", id);
  for (int i = 0; i < id; i++) {
    if (i) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
  return 0;
}
