#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[111111], b[111111], vis[111111];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  if (n == 1) {
    printf("1\n");
    printf("%d\n", a[0]);
    return 0;
  }
  sort(a, a + n);
  int sz = 2;
  int cnt = 0;
  b[0] = a[0];
  b[1] = a[1];
  for (int i = 2; i < n; i++) {
    if (a[i - 2] != a[i]) b[sz++] = a[i];
  }
  if (b[sz - 2] == b[sz - 1]) sz--;
  for (int i = 1; i < sz; i++) {
    if (b[i] == b[i - 1]) vis[cnt++] = b[i];
  }
  int unsz = unique(b, b + sz) - b;
  printf("%d\n", sz);
  for (int i = 0; i < unsz; i++) printf("%d ", b[i]);
  for (int i = cnt - 1; i >= 0; i--) printf("%d ", vis[i]);
  printf("\n");
  return 0;
}
